diff --git a/binaries/cuprated/src/logging.rs b/binaries/cuprated/src/logging.rs index 12079bc..e6d72b8 100644 --- a/binaries/cuprated/src/logging.rs +++ b/binaries/cuprated/src/logging.rs @@ -1,6 +1,8 @@ -use std::{mem::forget, sync::OnceLock}; - -use cuprate_helper::fs::logs_path; +use std::{ + fmt::{Display, Formatter}, + mem::forget, + sync::OnceLock, +}; use tracing::{ instrument::WithSubscriber, level_filters::LevelFilter, subscriber::Interest, Metadata, @@ -19,6 +21,8 @@ use tracing_subscriber::{ Layer, Registry, }; +use cuprate_helper::fs::logs_path; + use crate::config::Config; /// A [`OnceLock`] which holds the [`Handle`] to update the file logging output. @@ -50,6 +54,14 @@ pub struct CupratedTracingFilter { pub level: LevelFilter, } +impl Display for CupratedTracingFilter { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Filter") + .field("minimum_level", &self.level.to_string()) + .finish() + } +} + impl Filter for CupratedTracingFilter { fn enabled(&self, meta: &Metadata<'_>, cx: &Context<'_, S>) -> bool { Filter::::enabled(&self.level, meta, cx) diff --git a/binaries/cuprated/src/main.rs b/binaries/cuprated/src/main.rs index 52bde99..6f6afad 100644 --- a/binaries/cuprated/src/main.rs +++ b/binaries/cuprated/src/main.rs @@ -19,7 +19,7 @@ use tokio::sync::mpsc; use tower::{Service, ServiceExt}; use tracing::level_filters::LevelFilter; -use tracing_subscriber::{Registry, util::SubscriberInitExt, reload::Handle, layer::SubscriberExt}; +use tracing_subscriber::{layer::SubscriberExt, reload::Handle, util::SubscriberInitExt, Registry}; use cuprate_consensus_context::{ BlockChainContextRequest, BlockChainContextResponse, BlockChainContextService, @@ -156,9 +156,10 @@ async fn io_loop( while let Some(command) = incoming_commands.recv().await { match command { Command::SetLog { level } => { - logging::modify_stdout_output(|filter| filter.level = level); - - println!("LOG LEVEL CHANGED: {level}"); + logging::modify_stdout_output(|filter| { + filter.level = level; + println!("NEW LOG FILTER: {filter}"); + }); } Command::Status => { let BlockChainContextResponse::Context(blockchain_context) = context_service