From c5ce454319a7d54d3967c6ea7695543e943a37b2 Mon Sep 17 00:00:00 2001 From: Nathan Perry Date: Fri, 16 Aug 2024 07:12:33 -0400 Subject: tracing: use fields rather than interpolation --- src/commands/meme/create.rs | 4 ++-- src/commands/meme/delete.rs | 2 +- src/commands/meme/history.rs | 9 +++++---- src/commands/meme/mod.rs | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src/commands/meme') diff --git a/src/commands/meme/create.rs b/src/commands/meme/create.rs index a4e9656..c6ed9c6 100644 --- a/src/commands/meme/create.rs +++ b/src/commands/meme/create.rs @@ -109,7 +109,7 @@ pub async fn addaudiomeme( util::react(ctx, '🔃').await?; let youtube_url = util::ytdl_url(audio_link.as_str()).await?; - tracing::debug!("got download url: {youtube_url}"); + tracing::debug!(url_string = &youtube_url, "got download url"); let duration_opts = if let Some(e) = end { vec![ @@ -162,7 +162,7 @@ pub async fn addaudiomeme( let mut audio_data = Vec::new(); let bytes = audio_reader.read_to_end(&mut audio_data).await?; - tracing::debug!("downloaded audio ({} bytes)", audio_data.len()); + tracing::debug!(len_bytes = audio_data.len(), "downloaded audio"); if bytes == 0 { tracing::debug!("read 0 bytes from audio reader"); diff --git a/src/commands/meme/delete.rs b/src/commands/meme/delete.rs index 560da28..8adaa6c 100644 --- a/src/commands/meme/delete.rs +++ b/src/commands/meme/delete.rs @@ -26,7 +26,7 @@ pub async fn delmeme(ctx: PoiseContext<'_>, title: String) -> anyhow::Result<()> }, Err(e) => { if let Some(NotFound) = e.downcast_ref::() { - tracing::info!("attempted to delete nonexistent meme: '{}'", title); + tracing::info!(title, "attempted to delete nonexistent meme"); util::react(ctx, ReactionType::Unicode("❓".to_owned())).await?; util::reply(ctx, "nice try").await?; diff --git a/src/commands/meme/history.rs b/src/commands/meme/history.rs index e3d0de3..d6ccdcf 100644 --- a/src/commands/meme/history.rs +++ b/src/commands/meme/history.rs @@ -107,9 +107,10 @@ pub async fn history(ctx: PoiseContext<'_>, n: Option) -> anyhow::Result< if n > CONFIG.max_hist { tracing::debug!( - "user requested more than MAX_HIST ({}) items from history", - CONFIG.max_hist + MAX_HIST = CONFIG.max_hist, + "user requested more than MAX_HIST items from history", ); + util::reply(ctx, "YER PUSHIN ME OVER THE FUCKIN LINE").await?; } @@ -127,7 +128,7 @@ pub async fn history(ctx: PoiseContext<'_>, n: Option) -> anyhow::Result< return Ok(()); } - tracing::info!("reporting meme history (len {})", n); + tracing::info!(len = n, "reporting meme history"); let resp = serenity::futures::stream::iter(records.into_iter().enumerate().rev()) .then(|(i, rec)| async move { @@ -181,7 +182,7 @@ pub async fn history(ctx: PoiseContext<'_>, n: Option) -> anyhow::Result< Err(e) => { if let Some(variant) = e.downcast_ref::() { if *variant != NotFound { - tracing::error!("error encountered loading meme history: {}", e); + tracing::error!(error = %e, "error encountered loading meme history"); } } diff --git a/src/commands/meme/mod.rs b/src/commands/meme/mod.rs index 4819c1d..7bc8b2e 100644 --- a/src/commands/meme/mod.rs +++ b/src/commands/meme/mod.rs @@ -70,7 +70,7 @@ async fn send_meme( let should_tts = t.content.as_ref().map(|t| !t.is_empty()).unwrap_or(false) && random::() % 25 == 0; - tracing::debug!("sending meme (tts: {}): {:?}", should_tts, t); + tracing::debug!(should_tts, meme = ?t, "sending meme"); let image = t.image(conn).await; let audio = t.audio(conn).await; -- cgit v1.3.1