From 46808a85e667bc3db1906f353f7340775a2d22b5 Mon Sep 17 00:00:00 2001 From: Vidhan Bhatt Date: Fri, 17 Nov 2023 21:23:45 -0500 Subject: [PATCH] feat: switch to `tracing` --- Cargo.lock | 222 ++++++++++---------- Cargo.toml | 4 +- examples/basic_structure/main.rs | 5 +- examples/event_handler/main.rs | 5 +- examples/fluent_localization/main.rs | 5 +- examples/fluent_localization/translation.rs | 2 +- src/builtins/mod.rs | 18 +- src/builtins/register.rs | 2 +- src/dispatch/common.rs | 4 +- src/dispatch/mod.rs | 2 +- src/dispatch/slash.rs | 10 +- src/framework/builder.rs | 2 +- src/framework/mod.rs | 4 +- src/modal.rs | 6 +- src/structs/context.rs | 2 +- src/structs/framework_options.rs | 2 +- 16 files changed, 156 insertions(+), 139 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b0901582f1f6..3d1539c6cd7c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -107,12 +107,6 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" -[[package]] -name = "bitflags" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" - [[package]] name = "block-buffer" version = "0.10.4" @@ -301,40 +295,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "env_logger" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" -dependencies = [ - "humantime", - "is-terminal", - "log", - "regex", - "termcolor", -] - -[[package]] -name = "errno" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" -dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "flate2" version = "1.0.27" @@ -579,12 +539,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.27" @@ -697,17 +651,6 @@ version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" -[[package]] -name = "is-terminal" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" -dependencies = [ - "hermit-abi", - "rustix", - "windows-sys", -] - [[package]] name = "itoa" version = "1.0.9" @@ -724,16 +667,16 @@ dependencies = [ ] [[package]] -name = "libc" -version = "0.2.147" +name = "lazy_static" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] -name = "linux-raw-sys" -version = "0.4.7" +name = "libc" +version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "lock_api" @@ -751,6 +694,15 @@ version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + [[package]] name = "memchr" version = "2.6.3" @@ -793,6 +745,16 @@ dependencies = [ "windows-sys", ] +[[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-traits" version = "0.2.16" @@ -836,6 +798,12 @@ dependencies = [ "num-traits", ] +[[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.1" @@ -883,20 +851,20 @@ version = "0.5.7" dependencies = [ "async-trait", "derivative", - "env_logger", "fluent", "fluent-syntax", "futures", "futures-core", "futures-util", "intl-memoizer", - "log", "once_cell", "parking_lot", "poise_macros", "regex", "serenity", "tokio", + "tracing", + "tracing-subscriber", ] [[package]] @@ -969,7 +937,7 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ - "bitflags 1.3.2", + "bitflags", ] [[package]] @@ -980,8 +948,17 @@ checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" dependencies = [ "aho-corasick", "memchr", - "regex-automata", - "regex-syntax", + "regex-automata 0.3.8", + "regex-syntax 0.7.5", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", ] [[package]] @@ -992,9 +969,15 @@ checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.7.5", ] +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + [[package]] name = "regex-syntax" version = "0.7.5" @@ -1070,19 +1053,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" -[[package]] -name = "rustix" -version = "0.38.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7db8590df6dfcd144d22afd1b83b36c21a18d7cbc1dc4bb5295a8712e9eb662" -dependencies = [ - "bitflags 2.4.0", - "errno", - "libc", - "linux-raw-sys", - "windows-sys", -] - [[package]] name = "rustls" version = "0.20.9" @@ -1222,7 +1192,7 @@ dependencies = [ "async-trait", "async-tungstenite", "base64 0.13.1", - "bitflags 1.3.2", + "bitflags", "bytes", "cfg-if", "chrono", @@ -1256,6 +1226,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 = "slab" version = "0.4.9" @@ -1325,15 +1304,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "termcolor" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" -dependencies = [ - "winapi-util", -] - [[package]] name = "thiserror" version = "1.0.48" @@ -1354,6 +1324,16 @@ dependencies = [ "syn 2.0.32", ] +[[package]] +name = "thread_local" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +dependencies = [ + "cfg-if", + "once_cell", +] + [[package]] name = "time" version = "0.3.28" @@ -1477,11 +1457,10 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "cfg-if", "log", "pin-project-lite", "tracing-attributes", @@ -1490,9 +1469,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", @@ -1501,11 +1480,41 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.31" +version = "0.1.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 = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ + "matchers", + "nu-ansi-term", "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", ] [[package]] @@ -1628,6 +1637,12 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" +[[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.4" @@ -1779,15 +1794,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index 203f35097c09..18b584975635 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ once_cell = { version = "1.7.2", default-features = false, features = ["std"] } poise_macros = { path = "macros", version = "0.5.7" } # remember to update the version on changes! async-trait = { version = "0.1.48", default-features = false } # various traits regex = { version = "1.6.0", default-features = false, features = ["std"] } # prefix -log = { version = "0.4.14", default-features = false } # warning about weird state +tracing = "0.1.40" derivative = "2.2.0" parking_lot = "0.12.1" @@ -29,7 +29,7 @@ version = "0.11.5" # For the examples tokio = { version = "1.25.1", features = ["rt-multi-thread"] } futures = { version = "0.3.13", default-features = false } -env_logger = "0.10.0" +tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } 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 b256ac5709af..b2608b8f893a 100644 --- a/examples/basic_structure/main.rs +++ b/examples/basic_structure/main.rs @@ -4,6 +4,7 @@ mod commands; use poise::serenity_prelude as serenity; use std::{collections::HashMap, env::var, sync::Mutex, time::Duration}; +use tracing_subscriber::EnvFilter; // Types used by all command functions type Error = Box; @@ -33,7 +34,9 @@ async fn on_error(error: poise::FrameworkError<'_, Data, Error>) { #[tokio::main] async fn main() { - env_logger::init(); + tracing_subscriber::fmt() + .with_env_filter(EnvFilter::from_default_env()) + .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 4ca5b3891139..43fa62fc30e3 100644 --- a/examples/event_handler/main.rs +++ b/examples/event_handler/main.rs @@ -3,6 +3,7 @@ use std::sync::atomic::{AtomicU32, Ordering}; use poise::serenity_prelude as serenity; use poise::Event; +use tracing_subscriber::EnvFilter; // Types used by all command functions type Error = Box; @@ -16,7 +17,9 @@ pub struct Data { #[tokio::main] async fn main() { - env_logger::init(); + tracing_subscriber::fmt() + .with_env_filter(EnvFilter::from_default_env()) + .init(); let options = poise::FrameworkOptions { event_handler: |_ctx, event, _framework, _data| { diff --git a/examples/fluent_localization/main.rs b/examples/fluent_localization/main.rs index 35b425c2d568..9b2f29988d26 100644 --- a/examples/fluent_localization/main.rs +++ b/examples/fluent_localization/main.rs @@ -1,6 +1,7 @@ mod translation; use poise::serenity_prelude as serenity; +use tracing_subscriber::EnvFilter; use translation::tr; pub struct Data { @@ -56,7 +57,9 @@ async fn register(ctx: Context<'_>) -> Result<(), Error> { #[tokio::main] async fn main() { - env_logger::init(); + tracing_subscriber::fmt() + .with_env_filter(EnvFilter::from_default_env()) + .init(); let mut commands = vec![welcome(), info(), register()]; let translations = translation::read_ftl().expect("failed to read translation files"); diff --git a/examples/fluent_localization/translation.rs b/examples/fluent_localization/translation.rs index 215d16488345..250c20e40650 100644 --- a/examples/fluent_localization/translation.rs +++ b/examples/fluent_localization/translation.rs @@ -59,7 +59,7 @@ pub fn get( .or_else(|| format(&translations.main, id, attr, args)) // If this message ID is not present in any translation files whatsoever .unwrap_or_else(|| { - log::warn!("unknown fluent message identifier `{}`", id); + tracing::warn!("unknown fluent message identifier `{}`", id); id.to_string() }) } diff --git a/src/builtins/mod.rs b/src/builtins/mod.rs index bb1a4bf80a20..a41e7291b3d3 100644 --- a/src/builtins/mod.rs +++ b/src/builtins/mod.rs @@ -16,8 +16,8 @@ pub use paginate::*; use crate::serenity_prelude as serenity; -/// An error handler that logs errors either via the [`log`] crate or via a Discord message. Set -/// up a logger (e.g. `env_logger::init()`) to see the logged errors from this method. +/// An error handler that logs errors either via the [`tracing`] crate or via a Discord message. Set +/// up a 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 /// help is displayed and the user is directed to the help menu. @@ -27,7 +27,7 @@ use crate::serenity_prelude as serenity; /// ```rust,no_run /// # async { let error: poise::FrameworkError<'_, (), &str> = todo!(); /// if let Err(e) = poise::builtins::on_error(error).await { -/// log::error!("Fatal error while sending error message: {}", e); +/// tracing::error!("Fatal error while sending error message: {}", e); /// } /// # }; /// ``` @@ -38,7 +38,7 @@ pub async fn on_error( crate::FrameworkError::Setup { error, .. } => { eprintln!("Error in user data setup: {}", error); } - crate::FrameworkError::EventHandler { error, event, .. } => log::error!( + crate::FrameworkError::EventHandler { error, event, .. } => tracing::error!( "User event event handler encountered an error on {} event: {}", event.name(), error @@ -91,14 +91,14 @@ pub async fn on_error( ctx.say(response).await?; } crate::FrameworkError::CommandStructureMismatch { ctx, description } => { - log::error!( + tracing::error!( "Error: failed to deserialize interaction arguments for `/{}`: {}", ctx.command.name, description, ); } crate::FrameworkError::CommandCheckFailed { ctx, error } => { - log::error!( + tracing::error!( "A command check failed in command {} for user {}: {:?}", ctx.command().name, ctx.author().name, @@ -162,7 +162,7 @@ pub async fn on_error( ctx.send(|b| b.content(response).ephemeral(true)).await?; } crate::FrameworkError::DynamicPrefix { error, msg, .. } => { - log::error!( + tracing::error!( "Dynamic prefix failed for message {:?}: {}", msg.content, error @@ -173,14 +173,14 @@ pub async fn on_error( prefix, .. } => { - log::warn!( + tracing::warn!( "Recognized prefix `{}`, but didn't recognize command name in `{}`", prefix, msg_content, ); } crate::FrameworkError::UnknownInteraction { interaction, .. } => { - log::warn!( + tracing::warn!( "received unknown interaction \"{}\"", interaction.data().name ); diff --git a/src/builtins/register.rs b/src/builtins/register.rs index efad0c271f5a..e422a53a5326 100644 --- a/src/builtins/register.rs +++ b/src/builtins/register.rs @@ -244,7 +244,7 @@ pub async fn register_application_commands_buttons( "register.guild" => (true, false), "unregister.guild" => (false, false), other => { - log::warn!("unknown register button ID: {:?}", other); + tracing::warn!("unknown register button ID: {:?}", other); return Ok(()); } }; diff --git a/src/dispatch/common.rs b/src/dispatch/common.rs index 0ffbae78795b..ac88342aa3f7 100644 --- a/src/dispatch/common.rs +++ b/src/dispatch/common.rs @@ -21,7 +21,7 @@ async fn user_permissions( let channel = match channel_id.to_channel(ctx).await { Ok(serenity::Channel::Guild(channel)) => channel, Ok(_other_channel) => { - log::warn!( + tracing::warn!( "guild message was supposedly sent in a non-guild channel. Denying invocation" ); return None; @@ -97,7 +97,7 @@ async fn check_permissions_and_cooldown_single<'a, U, E>( let channel = match ctx.channel_id().to_channel(ctx.serenity_context()).await { Ok(channel) => channel, Err(e) => { - log::warn!("Error when getting channel: {}", e); + tracing::warn!("Error when getting channel: {}", e); return Err(crate::FrameworkError::NsfwOnly { ctx }); } diff --git a/src/dispatch/mod.rs b/src/dispatch/mod.rs index bdd8e809b189..1022dfcd0f3a 100644 --- a/src/dispatch/mod.rs +++ b/src/dispatch/mod.rs @@ -124,7 +124,7 @@ pub async fn dispatch_event( .process_message_delete(*deleted_message_id); if let Some(bot_response) = bot_response { if let Err(e) = bot_response.delete(ctx).await { - log::warn!("failed to delete bot response: {}", e); + tracing::warn!("failed to delete bot response: {}", e); } } } diff --git a/src/dispatch/slash.rs b/src/dispatch/slash.rs index d740d27efb7d..2e9758e4aa0f 100644 --- a/src/dispatch/slash.rs +++ b/src/dispatch/slash.rs @@ -141,7 +141,7 @@ async fn run_command( } } other => { - log::warn!("unknown interaction command type: {:?}", other); + tracing::warn!("unknown interaction command type: {:?}", other); return Ok(()); } }; @@ -194,7 +194,7 @@ async fn run_autocomplete( let focused_option = match ctx.args.iter().find(|o| o.focused) { Some(x) => x, None => { - log::warn!("no option is focused in autocomplete interaction"); + tracing::warn!("no option is focused in autocomplete interaction"); return Ok(()); } }; @@ -232,7 +232,7 @@ async fn run_autocomplete( let autocomplete_response = match autocomplete_callback(ctx, partial_input).await { Ok(x) => x, Err(e) => { - log::warn!("couldn't generate autocomplete response: {}", e); + tracing::warn!("couldn't generate autocomplete response: {}", e); return Ok(()); } }; @@ -240,7 +240,7 @@ async fn run_autocomplete( let interaction = match ctx.interaction { crate::ApplicationCommandOrAutocompleteInteraction::Autocomplete(x) => x, _ => { - log::warn!("a non-autocomplete interaction was given to run_autocomplete()"); + tracing::warn!("a non-autocomplete interaction was given to run_autocomplete()"); return Ok(()); } }; @@ -253,7 +253,7 @@ async fn run_autocomplete( }) .await { - log::warn!("couldn't send autocomplete response: {}", e); + tracing::warn!("couldn't send autocomplete response: {}", e); } Ok(()) diff --git a/src/framework/builder.rs b/src/framework/builder.rs index f339fb106fc8..76d1c2d633e8 100644 --- a/src/framework/builder.rs +++ b/src/framework/builder.rs @@ -211,7 +211,7 @@ and enable MESSAGE_CONTENT in your Discord bot dashboard options.commands.extend(self.commands); if self.initialize_owners { if let Err(e) = super::insert_owners_from_http(&token, &mut options.owners).await { - log::warn!("Failed to insert owners from HTTP: {}", e); + tracing::warn!("Failed to insert owners from HTTP: {}", e); } } diff --git a/src/framework/mod.rs b/src/framework/mod.rs index 523a161215d0..8aa19651833f 100644 --- a/src/framework/mod.rs +++ b/src/framework/mod.rs @@ -290,7 +290,9 @@ fn message_content_intent_sanity_check( || prefix_options.stripped_dynamic_prefix.is_some(); let can_receive_message_content = intents.contains(serenity::GatewayIntents::MESSAGE_CONTENT); if is_prefix_configured && !can_receive_message_content { - log::warn!("Warning: MESSAGE_CONTENT intent not set; prefix commands will not be received"); + tracing::warn!( + "Warning: MESSAGE_CONTENT intent not set; prefix commands will not be received" + ); } } diff --git a/src/modal.rs b/src/modal.rs index 5cf4086b23a4..ea450fe2ae33 100644 --- a/src/modal.rs +++ b/src/modal.rs @@ -16,11 +16,11 @@ pub fn find_modal_text( let text = match row.components.get_mut(0) { Some(serenity::ActionRowComponent::InputText(text)) => text, Some(_) => { - log::warn!("unexpected non input text component in modal response"); + tracing::warn!("unexpected non input text component in modal response"); continue; } None => { - log::warn!("empty action row in modal response"); + tracing::warn!("empty action row in modal response"); continue; } }; @@ -30,7 +30,7 @@ pub fn find_modal_text( return if value.is_empty() { None } else { Some(value) }; } } - log::warn!( + tracing::warn!( "{} not found in modal response (expected at least blank string)", custom_id ); diff --git a/src/structs/context.rs b/src/structs/context.rs index 877a5c5ac47c..7db8c3cbaa26 100644 --- a/src/structs/context.rs +++ b/src/structs/context.rs @@ -504,7 +504,7 @@ context_methods! { match self.framework().shard_manager.lock().await.runners.lock().await.get(&serenity::ShardId(self.serenity_context().shard_id)) { Some(runner) => runner.latency.unwrap_or(std::time::Duration::ZERO), None => { - log::error!("current shard is not in shard_manager.runners, this shouldn't happen"); + tracing::error!("current shard is not in shard_manager.runners, this shouldn't happen"); std::time::Duration::ZERO } } diff --git a/src/structs/framework_options.rs b/src/structs/framework_options.rs index 92663bae2ca0..a0e9651f63ee 100644 --- a/src/structs/framework_options.rs +++ b/src/structs/framework_options.rs @@ -94,7 +94,7 @@ where on_error: |error| { Box::pin(async move { if let Err(e) = crate::builtins::on_error(error).await { - log::error!("Error while handling error: {}", e); + tracing::error!("Error while handling error: {}", e); } }) },