Skip to content

Commit

Permalink
Tweaking some tracing messages
Browse files Browse the repository at this point in the history
  • Loading branch information
NotNorom committed Sep 17, 2023
1 parent f91c3f6 commit d957847
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/album_provider/imgur_album.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::str::FromStr;
use imgurs::ImgurClient;
use poise::async_trait;
use reqwest::Url;
use tracing::{instrument, info};
use tracing::instrument;

use super::{Provider, ProviderError};

Expand All @@ -30,7 +30,6 @@ impl Provider for Imgur {
.map(|image_info| image_info.link.clone())
.filter_map(|link| Url::from_str(&link).ok())
.collect();
info!("Number of images available for {album_id}: {}", images.len());

Ok(images)
}
Expand Down
14 changes: 6 additions & 8 deletions src/startup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl State {
}
}

/// Sets up the user data:
/// Sets up the state:
/// - Creates a task that handles the banner queue
/// - Sets up a reqwest client
/// - Sets up the database pool
Expand All @@ -84,7 +84,7 @@ pub async fn setup(
_ready: &serenity_prelude::Ready,
framework: &Framework<Data, Error>,
) -> Result<Data, Error> {
info!("Setting up user data");
info!("Setting up state");
let settings = Settings::get();
let capacity = settings.scheduler.capacity;

Expand All @@ -101,22 +101,21 @@ pub async fn setup(

let state = {
let db = database.clone();
let ctx2 = ctx.clone();
let ctx = ctx.clone();
let http = reqw_client.clone();
let owners = owners.clone();

let callback = |schedule, handle| async move {
info!("Creating changer task for schedule {schedule:?}");
let task = ChangerTask::new(ctx2.clone(), db.clone(), http.clone(), providers, schedule);
info!("Running task now");
let task = ChangerTask::new(ctx.clone(), db.clone(), http.clone(), providers, schedule);

let Err(err) = task.run().await else {
info!("Task finished successfully");
return;
};
error!("In changer task: {err:?}");

let Err(critical_err) = err.handle_error(ctx2, handle, db, owners).await else {
let Err(critical_err) = err.handle_error(ctx, handle, db, owners).await else {
info!("Error happend and was handled successfully");
return;
};
Expand All @@ -132,9 +131,8 @@ pub async fn setup(
};

// schedule already existing guilds

let known_guild_ids: Vec<u64> = state.database().active_schedules().await?;
info!("Known guild id's: {:?}", known_guild_ids);
info!("Amount of active schedules: {}", known_guild_ids.len());

for id in known_guild_ids {
let entry = state.database().get::<GuildSchedule>(id).await?;
Expand Down

0 comments on commit d957847

Please sign in to comment.