From 7968700aaead95c6c0661524b4524bd4de940bbe Mon Sep 17 00:00:00 2001 From: Scott Lamb Date: Thu, 8 May 2025 10:48:53 -0700 Subject: [PATCH] fix missing log lines ...by using a global rather than per-layer filter with `tracing`. --- CHANGELOG.md | 5 ++++ server/base/tracing_setup.rs | 45 +++++++++++++++++++----------------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 458f3f9..5cae19d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ upgrades, e.g. `v0.6.x` -> `v0.7.x`. The config file format and [API](ref/api.md) currently have no stability guarantees, so they may change even on minor releases, e.g. `v0.7.5` -> `v0.7.6`. +## unreleased + +* switch from per-layer to global `tracing` filter to avoid missing log lines + (tokio-rs/tracing#2519)[https://github.com/tokio-rs/tracing/issues/2519]). + ## v0.7.21 (2025-04-04) * Release with `mimalloc` allocator, which is significantly faster than the memory diff --git a/server/base/tracing_setup.rs b/server/base/tracing_setup.rs index 7cb1f1a..ed799c8 100644 --- a/server/base/tracing_setup.rs +++ b/server/base/tracing_setup.rs @@ -122,33 +122,36 @@ pub fn install() { match std::env::var("MOONFIRE_FORMAT") { Ok(s) if s == "systemd" => { - let sub = tracing_subscriber::registry().with( - tracing_subscriber::fmt::Layer::new() - .with_writer(std::io::stderr) - .with_ansi(false) - .event_format(FormatSystemd) - .with_filter(filter), - ); + let sub = tracing_subscriber::registry() + .with( + tracing_subscriber::fmt::Layer::new() + .with_writer(std::io::stderr) + .with_ansi(false) + .event_format(FormatSystemd), + ) + .with(filter); tracing::subscriber::set_global_default(sub).unwrap(); } Ok(s) if s == "json" => { - let sub = tracing_subscriber::registry().with( - tracing_subscriber::fmt::Layer::new() - .with_writer(std::io::stderr) - .with_thread_names(true) - .json() - .with_filter(filter), - ); + let sub = tracing_subscriber::registry() + .with( + tracing_subscriber::fmt::Layer::new() + .with_writer(std::io::stderr) + .with_thread_names(true) + .json(), + ) + .with(filter); tracing::subscriber::set_global_default(sub).unwrap(); } _ => { - let sub = tracing_subscriber::registry().with( - tracing_subscriber::fmt::Layer::new() - .with_writer(std::io::stderr) - .with_timer(JiffTimer) - .with_thread_names(true) - .with_filter(filter), - ); + let sub = tracing_subscriber::registry() + .with( + tracing_subscriber::fmt::Layer::new() + .with_writer(std::io::stderr) + .with_timer(JiffTimer) + .with_thread_names(true), + ) + .with(filter); tracing::subscriber::set_global_default(sub).unwrap(); } }