mirror of
https://github.com/Cuprate/cuprate.git
synced 2025-01-03 17:39:50 +00:00
add more info to output when changing log level
This commit is contained in:
parent
ed822eb165
commit
647fd09ed4
2 changed files with 20 additions and 7 deletions
|
@ -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<S> Filter<S> for CupratedTracingFilter {
|
||||
fn enabled(&self, meta: &Metadata<'_>, cx: &Context<'_, S>) -> bool {
|
||||
Filter::<S>::enabled(&self.level, meta, cx)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue