Log improvement

This commit is contained in:
xavo95 2024-11-01 20:27:31 +01:00
parent af97b37e51
commit 44e7ec1527
Signed by: xavo95
GPG key ID: CBF8ADED6DEBB783

View file

@ -1,5 +1,4 @@
use tracing::Level; use tracing::Level;
use tracing_subscriber::fmt::writer::MakeWriterExt;
use tracing_subscriber::layer::SubscriberExt; use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt; use tracing_subscriber::util::SubscriberInitExt;
@ -17,16 +16,13 @@ pub fn init_axum(max_level: Level) {
// axum logs rejections from built-in extractors with the `axum::rejection` // axum logs rejections from built-in extractors with the `axum::rejection`
// target, at `TRACE` level. `axum::rejection=trace` enables showing those events // target, at `TRACE` level. `axum::rejection=trace` enables showing those events
format!( format!(
"{}=debug,tower_http=debug,axum::rejection=trace", "{}={},tower_http={},axum::rejection=trace",
env!("CARGO_CRATE_NAME") env!("CARGO_CRATE_NAME"),
) max_level.as_str(),
.into() max_level.as_str()
).into()
}), }),
) )
.with( .with(tracing_subscriber::fmt::layer().with_target(false))
tracing_subscriber::fmt::layer()
.with_writer(std::io::stdout.with_max_level(max_level))
.with_target(false)
)
.init(); .init();
} }