From f5c303a6a7eda1aabb9f79af3eb378d5b1dece27 Mon Sep 17 00:00:00 2001 From: jamesbt365 Date: Sun, 24 Nov 2024 20:43:01 +0000 Subject: [PATCH] Change references of env_logger to tracing-subscriber --- Cargo.lock | 144 ++++++++++++++++++--------- Cargo.toml | 2 +- examples/basic_structure/main.rs | 2 +- examples/event_handler/main.rs | 2 +- examples/feature_showcase/main.rs | 2 +- examples/fluent_localization/main.rs | 2 +- src/builtins/mod.rs | 2 +- 7 files changed, 103 insertions(+), 53 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7d70c8d1cc78..f5777f2a85f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -363,19 +363,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "env_logger" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" -dependencies = [ - "humantime", - "is-terminal", - "log", - "regex", - "termcolor", -] - [[package]] name = "equivalent" version = "1.0.1" @@ -632,12 +619,6 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" -[[package]] -name = "hermit-abi" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" - [[package]] name = "http" version = "0.2.12" @@ -683,12 +664,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - [[package]] name = "hyper" version = "0.14.31" @@ -930,17 +905,6 @@ version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" -[[package]] -name = "is-terminal" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" -dependencies = [ - "hermit-abi 0.4.0", - "libc", - "windows-sys 0.52.0", -] - [[package]] name = "itoa" version = "1.0.11" @@ -956,6 +920,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + [[package]] name = "libc" version = "0.2.162" @@ -1042,12 +1012,22 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ - "hermit-abi 0.3.9", + "hermit-abi", "libc", "wasi", "windows-sys 0.52.0", ] +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + [[package]] name = "num-conv" version = "0.1.0" @@ -1078,6 +1058,12 @@ version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + [[package]] name = "parking_lot" version = "0.12.3" @@ -1125,7 +1111,6 @@ version = "0.6.1" dependencies = [ "async-trait", "derivative", - "env_logger", "fluent", "fluent-syntax", "futures", @@ -1139,6 +1124,7 @@ dependencies = [ "serenity", "tokio", "tracing", + "tracing-subscriber", "trim-in-place", ] @@ -1572,6 +1558,15 @@ dependencies = [ "digest", ] +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + [[package]] name = "shlex" version = "1.3.0" @@ -1721,15 +1716,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - [[package]] name = "thiserror" version = "1.0.69" @@ -1750,6 +1736,16 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", +] + [[package]] name = "time" version = "0.3.36" @@ -1904,6 +1900,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "nu-ansi-term", + "sharded-slab", + "smallvec", + "thread_local", + "tracing-core", + "tracing-log", ] [[package]] @@ -2061,6 +2083,12 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "version_check" version = "0.9.5" @@ -2197,6 +2225,22 @@ dependencies = [ "rustls-pki-types", ] +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + [[package]] name = "winapi-util" version = "0.1.9" @@ -2206,6 +2250,12 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + [[package]] name = "windows-core" version = "0.52.0" diff --git a/Cargo.toml b/Cargo.toml index 443039bcb69b..b2e825d46d4a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ version = "0.12.4" # For the examples tokio = { version = "1.25.1", features = ["rt-multi-thread"] } futures = { version = "0.3.13", default-features = false } -env_logger = "0.10.1" +tracing-subscriber = "0.3.18" fluent = "0.16.0" intl-memoizer = "0.5.1" fluent-syntax = "0.11" diff --git a/examples/basic_structure/main.rs b/examples/basic_structure/main.rs index a97bc68b0795..32de696910a0 100644 --- a/examples/basic_structure/main.rs +++ b/examples/basic_structure/main.rs @@ -38,7 +38,7 @@ async fn on_error(error: poise::FrameworkError<'_, Data, Error>) { #[tokio::main] async fn main() { - env_logger::init(); + tracing_subscriber::fmt::init(); // FrameworkOptions contains all of poise's configuration option in one struct // Every option can be omitted to use its default value diff --git a/examples/event_handler/main.rs b/examples/event_handler/main.rs index 34fb9fbb2cf7..f7da7b5b29b3 100644 --- a/examples/event_handler/main.rs +++ b/examples/event_handler/main.rs @@ -15,7 +15,7 @@ pub struct Data { #[tokio::main] async fn main() { - env_logger::init(); + tracing_subscriber::fmt::init(); let token = var("DISCORD_TOKEN") .expect("Missing `DISCORD_TOKEN` env var, see README for more information."); diff --git a/examples/feature_showcase/main.rs b/examples/feature_showcase/main.rs index c5424df67395..a28aae6d1d8b 100644 --- a/examples/feature_showcase/main.rs +++ b/examples/feature_showcase/main.rs @@ -29,7 +29,7 @@ pub struct Data {} #[tokio::main] async fn main() { - env_logger::init(); + tracing_subscriber::fmt::init(); let framework = poise::Framework::builder() .options(poise::FrameworkOptions { diff --git a/examples/fluent_localization/main.rs b/examples/fluent_localization/main.rs index f215a3a99584..c63928d022dc 100644 --- a/examples/fluent_localization/main.rs +++ b/examples/fluent_localization/main.rs @@ -58,7 +58,7 @@ async fn register(ctx: Context<'_>) -> Result<(), Error> { #[tokio::main] async fn main() { - env_logger::init(); + tracing_subscriber::fmt::init(); let mut commands = vec![welcome(), info(), register()]; let translations = translation::read_ftl().expect("failed to read translation files"); diff --git a/src/builtins/mod.rs b/src/builtins/mod.rs index 45e8082563f6..bb80bb470437 100644 --- a/src/builtins/mod.rs +++ b/src/builtins/mod.rs @@ -20,7 +20,7 @@ pub use paginate::*; use crate::{serenity::CreateAllowedMentions, serenity_prelude as serenity, CreateReply}; /// An error handler that logs errors either via the [`tracing`] crate or via a Discord message. Set -/// up a logger (e.g. `env_logger::init()`) or a tracing subscriber +/// up a logger like tracing subscriber /// (e.g. `tracing_subscriber::fmt::init()`) to see the logged errors from this method. /// /// If the user invoked the command wrong ([`crate::FrameworkError::ArgumentParse`]), the command