From 138172b365d445e814ba46513a51b90040430556 Mon Sep 17 00:00:00 2001 From: ayaka Date: Mon, 13 Jan 2025 14:18:05 +1300 Subject: [PATCH] unnecessary log generation --- src/client.rs | 4 ++-- src/oauth.rs | 4 ++-- src/subreddit.rs | 3 +++ src/user.rs | 2 ++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/client.rs b/src/client.rs index 248fc88..ff3b580 100644 --- a/src/client.rs +++ b/src/client.rs @@ -7,7 +7,7 @@ use hyper::header::HeaderValue; use hyper::{body, body::Buf, header, Body, Client, Method, Request, Response, Uri}; use hyper_rustls::HttpsConnector; use libflate::gzip; -use log::{error, trace, warn}; +use log::{error, debug, warn}; use once_cell::sync::Lazy; use percent_encoding::{percent_encode, CONTROLS}; use serde_json::Value; @@ -396,7 +396,7 @@ pub async fn json(path: String, quarantine: bool) -> Result { response.headers().get("x-ratelimit-reset").and_then(|val| val.to_str().ok().map(|s| s.to_string())), response.headers().get("x-ratelimit-used").and_then(|val| val.to_str().ok().map(|s| s.to_string())), ) { - trace!( + debug!( "Ratelimit remaining: Header says {remaining}, we have {current_rate_limit}. Resets in {reset}. Rollover: {}. Ratelimit used: {used}", if is_rolling_over { "yes" } else { "no" }, ); diff --git a/src/oauth.rs b/src/oauth.rs index 80bf318..c68e50a 100644 --- a/src/oauth.rs +++ b/src/oauth.rs @@ -6,7 +6,7 @@ use crate::{ }; use base64::{engine::general_purpose, Engine as _}; use hyper::{client, Body, Method, Request}; -use log::{error, info, trace}; +use log::{error, info, debug, trace}; use serde_json::json; use tokio::time::{error::Elapsed, timeout}; @@ -160,7 +160,7 @@ pub async fn force_refresh_token() { return; } - trace!("Rolling over refresh token. Current rate limit: {}", OAUTH_RATELIMIT_REMAINING.load(Ordering::SeqCst)); + debug!("Rolling over refresh token. Current rate limit: {}", OAUTH_RATELIMIT_REMAINING.load(Ordering::SeqCst)); let new_client = Oauth::new().await; OAUTH_CLIENT.swap(new_client.into()); OAUTH_RATELIMIT_REMAINING.store(99, Ordering::SeqCst); diff --git a/src/subreddit.rs b/src/subreddit.rs index 5f964ef..1ae90d3 100644 --- a/src/subreddit.rs +++ b/src/subreddit.rs @@ -13,6 +13,7 @@ use rinja::Template; use once_cell::sync::Lazy; use regex::Regex; use time::{Duration, OffsetDateTime}; +use log::trace; // STRUCTS #[derive(Template)] @@ -461,6 +462,8 @@ async fn subreddit(sub: &str, quarantined: bool) -> Result { // Send a request to the url let res = json(path, quarantined).await?; + trace!("Subreddit info from r/{} : {}",sub,res["data"]); + // Metadata regarding the subreddit let members: i64 = res["data"]["subscribers"].as_u64().unwrap_or_default() as i64; let active: i64 = res["data"]["accounts_active"].as_u64().unwrap_or_default() as i64; diff --git a/src/user.rs b/src/user.rs index 50a4daa..5e8bfd7 100644 --- a/src/user.rs +++ b/src/user.rs @@ -8,6 +8,7 @@ use crate::{config, utils}; use hyper::{Body, Request, Response}; use rinja::Template; use time::{macros::format_description, OffsetDateTime}; +use log::trace; // STRUCTS #[derive(Template)] @@ -111,6 +112,7 @@ async fn user(name: &str) -> Result { // Send a request to the url json(path, false).await.map(|res| { + trace!("User info from r/{} : {}",name,res["data"]); // Grab creation date as unix timestamp let created_unix = res["data"]["created"].as_f64().unwrap_or(0.0).round() as i64; let created = OffsetDateTime::from_unix_timestamp(created_unix).unwrap_or(OffsetDateTime::UNIX_EPOCH);