Print info about graceful shutdown to users

This commit is contained in:
Hirrolot 2021-06-27 15:44:46 +06:00
parent afe5a9716b
commit a6c480930a
3 changed files with 8 additions and 7 deletions

View file

@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Repls can now be stopped by `^C` signal.
- `Noop` and `AsyncStopToken`stop tokens.
- `StatefulListener`.
- Emit not only errors but also warnings and general information from teloxide, when set up by `enable_logging!`.
### Fixed

View file

@ -113,7 +113,7 @@ where
loop {
tokio::signal::ctrl_c().await.expect("Failed to listen for ^C");
log::debug!("^C receieved, trying to shutdown dispatcher");
log::info!("^C received, trying to shutdown the dispatcher...");
// If dispatcher wasn't running, then there is nothing to do
shutdown_inner(&state).ok();
@ -310,7 +310,7 @@ where
if let ShuttingDown = self.state.load() {
if let Some(token) = stop_token.take() {
log::debug!("Start shutting down dispatching");
log::debug!("Start shutting down dispatching...");
token.stop();
}
}
@ -324,9 +324,9 @@ where
// Notify `shutdown`s that we finished
self.shutdown_notify_back.notify_waiters();
log::debug!("Dispatching shut down");
log::info!("Dispatching has been shut down.");
} else {
log::debug!("Dispatching stopped (listener returned `None`)");
log::debug!("Dispatching has been stopped (listener returned `None`).");
}
self.state.store(Idle);

View file

@ -1,7 +1,7 @@
/// Enables logging through [pretty-env-logger].
///
/// A logger will **only** print errors from teloxide and **all** logs from
/// your program.
/// A logger will **only** print errors, warnings, and general information from
/// teloxide and **all** logs from your program.
///
/// # Example
/// ```no_compile
@ -46,7 +46,7 @@ macro_rules! enable_logging_with_filter {
pretty_env_logger::formatted_builder()
.write_style(pretty_env_logger::env_logger::WriteStyle::Auto)
.filter(Some(&env!("CARGO_PKG_NAME").replace("-", "_")), $filter)
.filter(Some("teloxide"), log::LevelFilter::Error)
.filter(Some("teloxide"), log::LevelFilter::Info)
.init();
};
}