From 9b372bf1e3020359017b2d6e9b003eadb96c53ab Mon Sep 17 00:00:00 2001 From: "Christoph J. Scherr" Date: Wed, 2 Aug 2023 13:50:14 +0200 Subject: [PATCH] add span formatting for logger --- src/logger/mod.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/logger/mod.rs b/src/logger/mod.rs index 2a99796..141bf84 100644 --- a/src/logger/mod.rs +++ b/src/logger/mod.rs @@ -24,7 +24,7 @@ use error::*; pub use tracing::{debug, error, info, trace, warn, Level}; use tracing_appender; -use tracing_subscriber::prelude::*; +use tracing_subscriber::{prelude::*, fmt::format::FmtSpan}; use pyo3::prelude::*; //// CONSTANTS ///////////////////////////////////////////////////////////////////////////////////// @@ -108,7 +108,11 @@ impl Logger { return Err(Error::Usage(format!("logging is already initialized"))); } else { let filter = tracing_subscriber::filter::FilterFn::new(|metadata| { - true + let mut filter = false; + filter |= metadata.target().contains(env!("CARGO_PKG_NAME")); + filter |= metadata.target().contains("pt"); + + filter }); let basic_subscriber = tracing_subscriber::fmt::Subscriber::builder() @@ -121,6 +125,7 @@ impl Logger { .with_thread_ids(display_thread_ids) .with_line_number(display_line_number) .with_thread_names(display_thread_names) + .with_span_events(FmtSpan::FULL) //.pretty // too verbose and over multiple lines, a bit like python tracebacks .finish() // add layers