mirror of
https://github.com/Cuprate/cuprate.git
synced 2025-03-21 22:58: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 std::{
|
||||||
|
fmt::{Display, Formatter},
|
||||||
use cuprate_helper::fs::logs_path;
|
mem::forget,
|
||||||
|
sync::OnceLock,
|
||||||
|
};
|
||||||
|
|
||||||
use tracing::{
|
use tracing::{
|
||||||
instrument::WithSubscriber, level_filters::LevelFilter, subscriber::Interest, Metadata,
|
instrument::WithSubscriber, level_filters::LevelFilter, subscriber::Interest, Metadata,
|
||||||
|
@ -19,6 +21,8 @@ use tracing_subscriber::{
|
||||||
Layer, Registry,
|
Layer, Registry,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use cuprate_helper::fs::logs_path;
|
||||||
|
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
|
|
||||||
/// A [`OnceLock`] which holds the [`Handle`] to update the file logging output.
|
/// A [`OnceLock`] which holds the [`Handle`] to update the file logging output.
|
||||||
|
@ -50,6 +54,14 @@ pub struct CupratedTracingFilter {
|
||||||
pub level: LevelFilter,
|
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 {
|
impl<S> Filter<S> for CupratedTracingFilter {
|
||||||
fn enabled(&self, meta: &Metadata<'_>, cx: &Context<'_, S>) -> bool {
|
fn enabled(&self, meta: &Metadata<'_>, cx: &Context<'_, S>) -> bool {
|
||||||
Filter::<S>::enabled(&self.level, meta, cx)
|
Filter::<S>::enabled(&self.level, meta, cx)
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use tower::{Service, ServiceExt};
|
use tower::{Service, ServiceExt};
|
||||||
use tracing::level_filters::LevelFilter;
|
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::{
|
use cuprate_consensus_context::{
|
||||||
BlockChainContextRequest, BlockChainContextResponse, BlockChainContextService,
|
BlockChainContextRequest, BlockChainContextResponse, BlockChainContextService,
|
||||||
|
@ -156,9 +156,10 @@ async fn io_loop(
|
||||||
while let Some(command) = incoming_commands.recv().await {
|
while let Some(command) = incoming_commands.recv().await {
|
||||||
match command {
|
match command {
|
||||||
Command::SetLog { level } => {
|
Command::SetLog { level } => {
|
||||||
logging::modify_stdout_output(|filter| filter.level = level);
|
logging::modify_stdout_output(|filter| {
|
||||||
|
filter.level = level;
|
||||||
println!("LOG LEVEL CHANGED: {level}");
|
println!("NEW LOG FILTER: {filter}");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
Command::Status => {
|
Command::Status => {
|
||||||
let BlockChainContextResponse::Context(blockchain_context) = context_service
|
let BlockChainContextResponse::Context(blockchain_context) = context_service
|
||||||
|
|
Loading…
Reference in a new issue