From 3c64df23bcec74ff98661d8ec139d8bcc18e430c Mon Sep 17 00:00:00 2001 From: VC Date: Tue, 8 Nov 2022 08:37:53 +0100 Subject: [PATCH] refactor: add info/debug --- src/lib.rs | 8 ++++---- src/util.rs | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 808b54d..b7edac0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,7 +20,7 @@ pub use state::{init_db, migrate_db}; use state::{read_state, write_state, TweetToToot}; use elefren::{prelude::*, status_builder::StatusBuilder}; -use log::{debug, info}; +use log::info; use rusqlite::Connection; use std::sync::Arc; use tokio::{spawn, sync::Mutex}; @@ -48,7 +48,7 @@ pub async fn run(config: Config) { let task_conn = conn.clone(); let task = spawn(async move { - debug!("Starting treating {}", &mastodon_config.twitter_screen_name); + info!("Starting treating {}", &mastodon_config.twitter_screen_name); // retrieve the last tweet ID for the username let lconn = task_conn.lock().await; @@ -81,7 +81,7 @@ pub async fn run(config: Config) { feed.reverse(); for tweet in &feed { - debug!("Treating Tweet {} inside feed", tweet.id); + info!("Treating Tweet {} inside feed", tweet.id); // initiate the toot_reply_id var let mut toot_reply_id: Option = None; // determine if the tweet is part of a thread (response to self) or a standard response @@ -113,7 +113,7 @@ pub async fn run(config: Config) { status_text = status_text.replace(&media_url, ""); - debug!("Building corresponding Mastodon status"); + info!("Building corresponding Mastodon status"); let mut status_builder = StatusBuilder::new(); diff --git a/src/util.rs b/src/util.rs index b2549e6..d113fa5 100644 --- a/src/util.rs +++ b/src/util.rs @@ -31,6 +31,8 @@ pub async fn generate_media_ids( // size of media_ids vector, should be equal to the media vector media_ids.resize(m.media.len(), String::new()); + info!("{} medias in tweet", m.media.len()); + for (i, media) in m.media.iter().enumerate() { // attribute media url media_url = media.url.clone(); @@ -41,10 +43,7 @@ pub async fn generate_media_ids( let mastodon = mastodon.clone(); let task = tokio::task::spawn(async move { -<<<<<<< HEAD -======= info!("Start treating {}", media.media_url_https); ->>>>>>> 32f9605 (tamerelol) // get the tweet embedded media let local_tweet_media_path = match get_tweet_media(&media, &cache_path).await { Ok(l) => l, @@ -65,7 +64,7 @@ pub async fn generate_media_ids( return Err(ScootalooError::new(&format!( "Attachment {} cannot be uploaded to Mastodon Instance: {}", &local_tweet_media_path, e - ))) + ))); } }; @@ -88,6 +87,8 @@ pub async fn generate_media_ids( Err(e) => error!("Something went wrong when joining the main thread: {}", e), } } + } else { + info!("No media in tweet"); } // in case some media_ids slot remained empty due to errors, remove them