2020-02-13 23:23:22 +06:00
|
|
|
/// Enables logging through [pretty-env-logger].
|
|
|
|
///
|
2021-06-27 15:44:46 +06:00
|
|
|
/// A logger will **only** print errors, warnings, and general information from
|
|
|
|
/// teloxide and **all** logs from your program.
|
2020-02-13 23:23:22 +06:00
|
|
|
///
|
|
|
|
/// # Note
|
2022-02-05 01:01:24 +06:00
|
|
|
///
|
2020-02-13 23:23:22 +06:00
|
|
|
/// Calling this macro **is not mandatory**; you can setup if your own logger if
|
|
|
|
/// you want.
|
|
|
|
///
|
|
|
|
/// [pretty-env-logger]: https://crates.io/crates/pretty_env_logger
|
|
|
|
#[macro_export]
|
2022-03-21 18:53:59 +04:00
|
|
|
#[deprecated = "Choose logging implementation yourself"]
|
2020-02-13 23:23:22 +06:00
|
|
|
macro_rules! enable_logging {
|
|
|
|
() => {
|
2022-03-21 18:53:59 +04:00
|
|
|
#[allow(deprecated)]
|
2020-02-13 23:23:22 +06:00
|
|
|
teloxide::enable_logging_with_filter!(log::LevelFilter::Trace);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-02-13 23:45:16 +06:00
|
|
|
/// Enables logging through [pretty-env-logger] with a custom filter for your
|
|
|
|
/// program.
|
2020-02-13 23:23:22 +06:00
|
|
|
///
|
2021-06-27 16:36:36 +06:00
|
|
|
/// A logger will **only** print errors, warnings, and general information from
|
|
|
|
/// teloxide and restrict logs from your program by the specified filter.
|
2020-02-13 23:23:22 +06:00
|
|
|
///
|
|
|
|
/// # Example
|
2022-02-05 01:01:24 +06:00
|
|
|
///
|
2020-02-13 23:23:22 +06:00
|
|
|
/// Allow printing all logs from your program up to [`LevelFilter::Debug`] (i.e.
|
|
|
|
/// do not print traces):
|
|
|
|
///
|
2020-02-14 04:14:14 +06:00
|
|
|
/// ```no_compile
|
2020-02-13 23:23:22 +06:00
|
|
|
/// teloxide::enable_logging_with_filter!(log::LevelFilter::Debug);
|
|
|
|
/// ```
|
|
|
|
///
|
|
|
|
/// # Note
|
2022-02-05 01:01:24 +06:00
|
|
|
///
|
2020-02-13 23:23:22 +06:00
|
|
|
/// Calling this macro **is not mandatory**; you can setup if your own logger if
|
|
|
|
/// you want.
|
|
|
|
///
|
|
|
|
/// [pretty-env-logger]: https://crates.io/crates/pretty_env_logger
|
2020-02-13 23:45:16 +06:00
|
|
|
/// [`LevelFilter::Debug`]: https://docs.rs/log/0.4.10/log/enum.LevelFilter.html
|
2020-02-13 23:23:22 +06:00
|
|
|
#[macro_export]
|
2022-03-21 18:53:59 +04:00
|
|
|
#[deprecated = "Choose logging implementation yourself"]
|
2020-02-13 23:23:22 +06:00
|
|
|
macro_rules! enable_logging_with_filter {
|
|
|
|
($filter:expr) => {
|
|
|
|
pretty_env_logger::formatted_builder()
|
|
|
|
.write_style(pretty_env_logger::env_logger::WriteStyle::Auto)
|
2022-02-05 01:07:28 +06:00
|
|
|
.filter(Some(&env!("CARGO_CRATE_NAME").replace("-", "_")), $filter)
|
2021-06-27 15:44:46 +06:00
|
|
|
.filter(Some("teloxide"), log::LevelFilter::Info)
|
2020-02-13 23:23:22 +06:00
|
|
|
.init();
|
|
|
|
};
|
|
|
|
}
|