From 7724c54b4bd8edc9c9cca3e0ae1b459b4550e0fb Mon Sep 17 00:00:00 2001 From: Vika Date: Sun, 9 Jul 2023 01:32:31 +0300 Subject: main: use tracing_tree in debug builds This gives me much more readable traces. JSON logging is still superior in production, where logs are stored in systemd-journald and preferably need to be self-contained lines. --- kittybox-rs/src/main.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'kittybox-rs/src') diff --git a/kittybox-rs/src/main.rs b/kittybox-rs/src/main.rs index 3136924..68d3b01 100644 --- a/kittybox-rs/src/main.rs +++ b/kittybox-rs/src/main.rs @@ -147,10 +147,18 @@ where #[tokio::main] async fn main() { use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Registry}; + Registry::default() .with(EnvFilter::from_default_env()) - .with(tracing_subscriber::fmt::layer().json()) + //.with(tracing_subscriber::fmt::layer().json()) + .with( + #[cfg(debug_assertions)] + tracing_tree::HierarchicalLayer::new(2), + #[cfg(not(debug_assertions))] + tracing_subscriber::fmt::layer().json() + ) .init(); + //let _ = tracing_log::LogTracer::init(); info!("Starting the kittybox server..."); -- cgit 1.4.1