mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-31 16:40:37 +01:00
Merge pull request #559 from teloxide/deprecate_enable_logging
Deprecate `enable_logging!` in favour of configuring logging yourself
This commit is contained in:
commit
a4c147538b
18 changed files with 27 additions and 26 deletions
|
@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- `ErasedStorage`, a storage with an erased error type.
|
||||
- Allow the storage generic `S` be `?Sized` in `Dialogue` and `HandlerExt::enter_dialogue`.
|
||||
|
||||
### Deprecated
|
||||
|
||||
- `enable_logging!` and `enable_logging_with_filter!` macros
|
||||
|
||||
### Fixed
|
||||
|
||||
- Log `UpdateKind::Error` in `teloxide::dispatching2::Dispatcher`.
|
||||
|
|
15
README.md
15
README.md
|
@ -92,7 +92,7 @@ use teloxide::prelude2::*;
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
teloxide::enable_logging!();
|
||||
pretty_env_logger::init();
|
||||
log::info!("Starting dices_bot...");
|
||||
|
||||
let bot = Bot::from_env().auto_send();
|
||||
|
@ -164,7 +164,7 @@ async fn answer(
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
teloxide::enable_logging!();
|
||||
pretty_env_logger::init();
|
||||
log::info!("Starting simple_commands_bot...");
|
||||
|
||||
let bot = Bot::from_env().auto_send();
|
||||
|
@ -218,7 +218,7 @@ impl Default for State {
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
teloxide::enable_logging!();
|
||||
pretty_env_logger::init();
|
||||
log::info!("Starting dialogue_bot...");
|
||||
|
||||
let bot = Bot::from_env().auto_send();
|
||||
|
@ -338,15 +338,6 @@ Associated links:
|
|||
- [Marvin's Marvellous Guide to All Things Webhook](https://core.telegram.org/bots/webhooks)
|
||||
- [Using self-signed certificates](https://core.telegram.org/bots/self-signed)
|
||||
|
||||
**Q: Can I use different loggers?**
|
||||
|
||||
A: Yes. You can setup any logger, for example [fern]. teloxide has no specific requirements as it depends only on [log]. Remember that [`enable_logging!`] and [`enable_logging_with_filter!`] are just **optional** utilities.
|
||||
|
||||
[fern]: https://crates.io/crates/fern
|
||||
[log]: https://crates.io/crates/log
|
||||
[`enable_logging!`]: https://docs.rs/teloxide/latest/teloxide/macro.enable_logging.html
|
||||
[`enable_logging_with_filter!`]: https://docs.rs/teloxide/latest/teloxide/macro.enable_logging_with_filter.html
|
||||
|
||||
## Community bots
|
||||
|
||||
Feel free to propose your own bot to our collection!
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Usage
|
||||
|
||||
```
|
||||
$ cargo run --features="full" --example <example-name>
|
||||
$ RUST_LOG=info cargo run --features="full" --example <example-name>
|
||||
```
|
||||
|
||||
Don't forget to initialise the `TELOXIDE_TOKEN` environmental variable.
|
||||
|
|
|
@ -144,7 +144,7 @@ async fn action(
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
teloxide::enable_logging!();
|
||||
pretty_env_logger::init();
|
||||
log::info!("Starting admin_bot...");
|
||||
|
||||
let bot = teloxide::Bot::from_env().auto_send();
|
||||
|
|
|
@ -114,7 +114,7 @@ async fn callback_handler(
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn Error>> {
|
||||
teloxide::enable_logging!();
|
||||
pretty_env_logger::init();
|
||||
log::info!("Starting bot...");
|
||||
|
||||
let bot = Bot::from_env().auto_send();
|
||||
|
|
|
@ -43,6 +43,9 @@ pub enum Command {
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
pretty_env_logger::init();
|
||||
log::info!("Starting db_remember_bot...");
|
||||
|
||||
let bot = Bot::from_env().auto_send();
|
||||
|
||||
let storage: MyStorage = if std::env::var("DB_REMEMBER_REDIS").is_ok() {
|
||||
|
|
|
@ -41,7 +41,7 @@ impl Default for State {
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
teloxide::enable_logging!();
|
||||
pretty_env_logger::init();
|
||||
log::info!("Starting dialogue_bot...");
|
||||
|
||||
let bot = Bot::from_env().auto_send();
|
||||
|
|
|
@ -4,7 +4,7 @@ use teloxide::prelude2::*;
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
teloxide::enable_logging!();
|
||||
pretty_env_logger::init();
|
||||
log::info!("Starting dices_bot...");
|
||||
|
||||
let bot = Bot::from_env().auto_send();
|
||||
|
|
|
@ -13,7 +13,7 @@ use teloxide::{
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
teloxide::enable_logging!();
|
||||
pretty_env_logger::init();
|
||||
log::info!("Starting dispatching2_features_bot...");
|
||||
|
||||
let bot = Bot::from_env().auto_send();
|
||||
|
|
|
@ -36,7 +36,7 @@ use reqwest::{StatusCode, Url};
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
teloxide::enable_logging!();
|
||||
pretty_env_logger::init();
|
||||
log::info!("Starting heroku_ping_pong_bot...");
|
||||
|
||||
let bot = Bot::from_env().auto_send();
|
||||
|
|
|
@ -8,7 +8,7 @@ use teloxide::{
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
teloxide::enable_logging!();
|
||||
pretty_env_logger::init();
|
||||
log::info!("Starting inline_bot...");
|
||||
|
||||
let bot = Bot::from_env().auto_send();
|
||||
|
|
|
@ -19,7 +19,7 @@ use reqwest::{StatusCode, Url};
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
teloxide::enable_logging!();
|
||||
pretty_env_logger::init();
|
||||
log::info!("Starting heroku_ping_pong_bot...");
|
||||
|
||||
let bot = Bot::from_env().auto_send();
|
||||
|
|
|
@ -9,7 +9,7 @@ static MESSAGES_TOTAL: Lazy<AtomicU64> = Lazy::new(AtomicU64::default);
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
teloxide::enable_logging!();
|
||||
pretty_env_logger::init();
|
||||
log::info!("Starting shared_state_bot...");
|
||||
|
||||
let bot = Bot::from_env().auto_send();
|
||||
|
|
|
@ -37,7 +37,7 @@ async fn answer(
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
teloxide::enable_logging!();
|
||||
pretty_env_logger::init();
|
||||
log::info!("Starting simple_commands_bot...");
|
||||
|
||||
let bot = Bot::from_env().auto_send();
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
//!
|
||||
//! #[tokio::main]
|
||||
//! async fn main() {
|
||||
//! teloxide::enable_logging!();
|
||||
//! pretty_env_logger::init();
|
||||
//! log::info!("Starting dialogue_bot!");
|
||||
//!
|
||||
//! let bot = Bot::from_env().auto_send();
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
//!
|
||||
//! # #[tokio::main]
|
||||
//! # async fn main() {
|
||||
//! teloxide::enable_logging!();
|
||||
//! pretty_env_logger::init();
|
||||
//! log::info!("Starting shared_state_bot...");
|
||||
//!
|
||||
//! let bot = Bot::from_env().auto_send();
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
//!
|
||||
//! # #[tokio::main]
|
||||
//! # async fn main() {
|
||||
//! teloxide::enable_logging!();
|
||||
//! pretty_env_logger::init();
|
||||
//! log::info!("Starting dices_bot...");
|
||||
//!
|
||||
//! let bot = Bot::from_env().auto_send();
|
||||
|
|
|
@ -10,8 +10,10 @@
|
|||
///
|
||||
/// [pretty-env-logger]: https://crates.io/crates/pretty_env_logger
|
||||
#[macro_export]
|
||||
#[deprecated = "Choose logging implementation yourself"]
|
||||
macro_rules! enable_logging {
|
||||
() => {
|
||||
#[allow(deprecated)]
|
||||
teloxide::enable_logging_with_filter!(log::LevelFilter::Trace);
|
||||
};
|
||||
}
|
||||
|
@ -39,6 +41,7 @@ macro_rules! enable_logging {
|
|||
/// [pretty-env-logger]: https://crates.io/crates/pretty_env_logger
|
||||
/// [`LevelFilter::Debug`]: https://docs.rs/log/0.4.10/log/enum.LevelFilter.html
|
||||
#[macro_export]
|
||||
#[deprecated = "Choose logging implementation yourself"]
|
||||
macro_rules! enable_logging_with_filter {
|
||||
($filter:expr) => {
|
||||
pretty_env_logger::formatted_builder()
|
||||
|
|
Loading…
Reference in a new issue