From 461df76d9d7d76d01b8f5a9127eeb7df9002d471 Mon Sep 17 00:00:00 2001 From: mirsal Date: Mon, 25 Nov 2024 18:04:09 +0000 Subject: [PATCH] src: Unclutter logs by switching some info messages to debug --- src/feedreader.rs | 4 ++-- src/main.rs | 2 +- src/state.rs | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/feedreader.rs b/src/feedreader.rs index a07837d..5dd2b8c 100644 --- a/src/feedreader.rs +++ b/src/feedreader.rs @@ -56,7 +56,7 @@ pub async fn fetch_and_parse_feed(uri: &str) -> Result> { let http_client = reqwest::Client::builder().default_headers(headers).build()?; let response = http_client.get(uri).send().await?.text().await?; - info!("Got response, parsing feed from {}", uri); + debug!("Got response, parsing feed from {}", uri); let feed = parser::parse(response.as_bytes())?; let feed_title = match feed.title.clone() { @@ -64,7 +64,7 @@ pub async fn fetch_and_parse_feed(uri: &str) -> Result> { None => String::from("Untitled") }; - info!("Got feed with title \"{}\"", feed_title); + debug!("Got feed with title \"{}\"", feed_title); Ok(Feed { uri: String::from(uri), diff --git a/src/main.rs b/src/main.rs index 80fda23..78b620a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -75,7 +75,7 @@ async fn main() -> anyhow::Result<()> { }; let feed = if feed.is_none() { - info!("Sleeping for {} seconds before refreshing this feed", feed_config.delay); + debug!("Sleeping for {} seconds before refreshing this feed", feed_config.delay); sleep(Duration::from_secs(feed_config.delay)).await; continue; } else { diff --git a/src/state.rs b/src/state.rs index 0cd5cea..06c02dd 100644 --- a/src/state.rs +++ b/src/state.rs @@ -25,7 +25,7 @@ use std::{ use tokio::fs; use chrono::{ DateTime, Utc }; -use tracing::{ info }; +use tracing::{ info, debug }; use serde_yaml::mapping::Mapping as FeedReaderState; @@ -55,17 +55,16 @@ impl FeedReaderStateDb { ) -> () { { - info!("Updating feed reader state"); + debug!("Updating feed reader state"); self.state.lock().unwrap().insert(uri.into(), dt.timestamp().into()); } - info!("Persisting feed reader state"); self.persist().await.unwrap(); } #[tracing::instrument(ret, level="debug")] pub fn get(&self, uri: &str) -> Option> { - info!("Retrieving state for feed {}", uri); + debug!("Retrieving state for feed {}", uri); match self.state.lock().unwrap().get(uri) { Some(t) => DateTime::from_timestamp((*t).as_i64().unwrap(), 0), None => None @@ -79,6 +78,7 @@ impl FeedReaderStateDb { Ok(state) } + #[tracing::instrument(ret, level="debug")] async fn persist(&self) -> Result<(), Box> { let serialized_state = serde_yaml::to_string(&self.state)?; fs::write(self.filename.clone(), &serialized_state.as_bytes()).await?;