tracing-bunyan-formatter icon indicating copy to clipboard operation
tracing-bunyan-formatter copied to clipboard

Prevent infinite loop when using reserved fields

Open abusch opened this issue 2 years ago • 0 comments

Attempt at fixing #33 by explicitly setting parent: None when calling tracing::debug!() in BunyanFormattingLayer. Also check whether the event is a "root" event before resolving the "current context" in on_event().

Testing this was tricky, as it turns out the infinite loop only happens if the subscriber is installed globally (i.e with tracing::subscriber::set_global_default()). When using a thread-local subscriber, such as with tracing::subscriber::with_default(), tracing prevents you from re-entrantly acquiring the subscriber, returning a dummy NONE subscriber the second time (which means the logs from BunyanFormattingLayer are always lost in that case). See https://github.com/tokio-rs/tracing/blob/v0.1.x/tracing-core/src/dispatcher.rs#L384

closes: #33

abusch avatar Jul 16 '23 07:07 abusch