From 5a2dc4070c1d14f22a7671c6f82ca2f4578369bd Mon Sep 17 00:00:00 2001 From: Nathan Perry Date: Fri, 16 Aug 2024 06:40:25 -0400 Subject: rework logging to use tracing via grate --- src/commands/meme/create.rs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'src/commands/meme/create.rs') diff --git a/src/commands/meme/create.rs b/src/commands/meme/create.rs index 185e1f6..a4e9656 100644 --- a/src/commands/meme/create.rs +++ b/src/commands/meme/create.rs @@ -2,11 +2,7 @@ use std::process::Stdio; use anyhow::anyhow; use diesel::result::Error as DieselError; -use log::{ - debug, - error, - warn, -}; +use grate::tracing; use serenity::all::ReactionType; use tap::Pipe; use tokio::{ @@ -40,7 +36,7 @@ pub async fn addmeme( let image = util::msg(ctx).and_then(|msg| msg.attachments.first()); if image.is_none() && text.is_none() { - warn!("tried to create non-audio meme with no image or text"); + tracing::warn!("tried to create non-audio meme with no image or text"); util::reply(ctx, "hahAA it's empty xdddd").await?; return Ok(()); @@ -74,7 +70,7 @@ pub async fn addmeme( if let Some(DieselError::DatabaseError(DatabaseErrorKind::UniqueViolation, _)) = e.downcast_ref::() { - error!("tried to create meme that already exists"); + tracing::error!("tried to create meme that already exists"); util::react(ctx, '❌').await?; util::reply(ctx, "that meme already exists").await?; @@ -97,7 +93,7 @@ pub async fn addaudiomeme( audio_str: String, #[rest] text: Option, ) -> anyhow::Result<()> { - debug!("running addaudiomeme"); + tracing::debug!("running addaudiomeme"); let elems = audio_str.split_whitespace().collect::>(); @@ -113,7 +109,7 @@ pub async fn addaudiomeme( util::react(ctx, '🔃').await?; let youtube_url = util::ytdl_url(audio_link.as_str()).await?; - debug!("got download url: {youtube_url}"); + tracing::debug!("got download url: {youtube_url}"); let duration_opts = if let Some(e) = end { vec![ @@ -166,10 +162,10 @@ pub async fn addaudiomeme( let mut audio_data = Vec::new(); let bytes = audio_reader.read_to_end(&mut audio_data).await?; - debug!("downloaded audio ({} bytes)", audio_data.len()); + tracing::debug!("downloaded audio ({} bytes)", audio_data.len()); if bytes == 0 { - debug!("read 0 bytes from audio reader"); + tracing::debug!("read 0 bytes from audio reader"); util::unreact(ctx, '🔃').await?; util::reply(ctx, "🔇🔇🔇🔕🔕🔕🔕🔕🔇🔕🔕🔇🔕🔕📣📢📣📢📣").await?; @@ -200,7 +196,7 @@ pub async fn addaudiomeme( if let Some(DieselError::DatabaseError(DatabaseErrorKind::UniqueViolation, _)) = e.downcast_ref::() { - error!("tried to create meme that already exists"); + tracing::error!("tried to create meme that already exists"); util::react(ctx, ReactionType::Unicode("❌".to_owned())).await?; util::reply(ctx, "that meme already exists").await?; -- cgit v1.3.1