diff --git a/Cargo.lock b/Cargo.lock index 85b42e3b6721..e5c2e7f81c07 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -109,9 +109,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" [[package]] name = "block-buffer" @@ -303,9 +303,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece" dependencies = [ "humantime", "is-terminal", @@ -316,25 +316,14 @@ dependencies = [ [[package]] name = "errno" -version = "0.3.3" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" +checksum = "f258a7194e7f7c2a7837a8913aeab7fd8c383457034fa20ce4dd3dcb813e8eb8" 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" @@ -731,9 +720,9 @@ checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "linux-raw-sys" -version = "0.4.7" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128" +checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" [[package]] name = "lock_api" @@ -887,16 +876,15 @@ dependencies = [ "fluent", "fluent-syntax", "futures", - "futures-core", "futures-util", "intl-memoizer", - "log", "once_cell", "parking_lot", "poise_macros", "regex", "serenity", "tokio", + "tracing", ] [[package]] @@ -1076,7 +1064,7 @@ version = "0.38.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7db8590df6dfcd144d22afd1b83b36c21a18d7cbc1dc4bb5295a8712e9eb662" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "errno", "libc", "linux-raw-sys", @@ -1327,9 +1315,9 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.2.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449" dependencies = [ "winapi-util", ] @@ -1477,11 +1465,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 +1477,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,9 +1488,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", ] @@ -1781,9 +1768,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ "winapi", ] diff --git a/Cargo.toml b/Cargo.toml index 203f35097c09..70088b0e53af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,13 +10,12 @@ repository = "https://github.com/serenity-rs/poise/" [dependencies] tokio = { version = "1.25.1", default-features = false } # for async in general -futures-core = { version = "0.3.13", default-features = false } # for async in general futures-util = { version = "0.3.13", default-features = false } # for async in general once_cell = { version = "1.7.2", default-features = false, features = ["std"] } # to store and set user data 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 = { version = "0.1.40", features = ["log"] } # warning about weird state derivative = "2.2.0" parking_lot = "0.12.1" @@ -29,7 +28,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" +env_logger = "0.10.1" fluent = "0.16.0" intl-memoizer = "0.5.1" fluent-syntax = "0.11" 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..d296f56b7421 100644 --- a/src/builtins/mod.rs +++ b/src/builtins/mod.rs @@ -16,8 +16,9 @@ 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 logger (e.g. `env_logger::init()`) or 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 +28,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 +39,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 +92,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 +163,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 +174,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); } }) },