fix missing log lines

...by using a global rather than per-layer filter with `tracing`.
This commit is contained in:
Scott Lamb 2025-05-08 10:48:53 -07:00
parent 239256e2ba
commit 7968700aae
2 changed files with 29 additions and 21 deletions

View File

@ -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 [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`. 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) ## v0.7.21 (2025-04-04)
* Release with `mimalloc` allocator, which is significantly faster than the memory * Release with `mimalloc` allocator, which is significantly faster than the memory

View File

@ -122,33 +122,36 @@ pub fn install() {
match std::env::var("MOONFIRE_FORMAT") { match std::env::var("MOONFIRE_FORMAT") {
Ok(s) if s == "systemd" => { Ok(s) if s == "systemd" => {
let sub = tracing_subscriber::registry().with( let sub = tracing_subscriber::registry()
.with(
tracing_subscriber::fmt::Layer::new() tracing_subscriber::fmt::Layer::new()
.with_writer(std::io::stderr) .with_writer(std::io::stderr)
.with_ansi(false) .with_ansi(false)
.event_format(FormatSystemd) .event_format(FormatSystemd),
.with_filter(filter), )
); .with(filter);
tracing::subscriber::set_global_default(sub).unwrap(); tracing::subscriber::set_global_default(sub).unwrap();
} }
Ok(s) if s == "json" => { Ok(s) if s == "json" => {
let sub = tracing_subscriber::registry().with( let sub = tracing_subscriber::registry()
.with(
tracing_subscriber::fmt::Layer::new() tracing_subscriber::fmt::Layer::new()
.with_writer(std::io::stderr) .with_writer(std::io::stderr)
.with_thread_names(true) .with_thread_names(true)
.json() .json(),
.with_filter(filter), )
); .with(filter);
tracing::subscriber::set_global_default(sub).unwrap(); tracing::subscriber::set_global_default(sub).unwrap();
} }
_ => { _ => {
let sub = tracing_subscriber::registry().with( let sub = tracing_subscriber::registry()
.with(
tracing_subscriber::fmt::Layer::new() tracing_subscriber::fmt::Layer::new()
.with_writer(std::io::stderr) .with_writer(std::io::stderr)
.with_timer(JiffTimer) .with_timer(JiffTimer)
.with_thread_names(true) .with_thread_names(true),
.with_filter(filter), )
); .with(filter);
tracing::subscriber::set_global_default(sub).unwrap(); tracing::subscriber::set_global_default(sub).unwrap();
} }
} }