From cb7d3a79264e00bfbc858c28341e125e27188920 Mon Sep 17 00:00:00 2001 From: Tait Hoyem Date: Thu, 13 Jun 2024 14:28:36 -0600 Subject: [PATCH] Update logging --- odilia/src/logging.rs | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/odilia/src/logging.rs b/odilia/src/logging.rs index 5647f7c8..005b2d18 100644 --- a/odilia/src/logging.rs +++ b/odilia/src/logging.rs @@ -26,7 +26,8 @@ pub fn init(config: &ApplicationConfig) -> eyre::Result<()> { .with_span_retrace(true) .with_indent_lines(true) .with_ansi(false) - .with_wraparound(4); + .with_wraparound(4) + .with_timer(Uptime::default()); //this requires boxing because the types returned by this match block would be incompatible otherwise, since we return different layers, or modifications to a layer depending on what we get from the configuration. It is possible to do it otherwise, hopefully, but for now this would do let final_layer = match &config.log.logger { LoggingKind::File(path) => { @@ -43,23 +44,7 @@ pub fn init(config: &ApplicationConfig) -> eyre::Result<()> { tracing_subscriber::Registry::default() .with(env_filter) .with(ErrorLayer::default()) - .with(HierarchicalLayer::new(4) - .with_bracketed_fields(true) - .with_targets(true) - .with_deferred_spans(true) - .with_span_retrace(true) - .with_timer(Uptime::default()) - .with_indent_lines(true)); - //console_subscriber::ConsoleLayer::builder() - // // set how long the console will retain data from completed tasks - // .retention(Duration::from_secs(60)) - // // set the address the server is bound to - // .server_addr(([127, 0, 0, 1], 5555)) - // // ... other configurations ... - // .init(); - tracing::subscriber::set_global_default(subscriber) - .wrap_err("unable to init default logging layer")?; - //LogTracer appears to cause a deadlock after some time... cannot quite figure out why - //LogTracer::init().wrap_err("unable to init tracing log layer")?; + .with(final_layer) + .init(); Ok(()) }