tokio-rs / tracing

Application level tracing for Rust.
https://tracing.rs
MIT License
5.19k stars 677 forks source link

Multiline tracing_appender non_blocking #2911

Closed mateiandrei94 closed 4 months ago

mateiandrei94 commented 4 months ago

Feature Request

I'm writing this as a feature request rather than a bug because of the documentation, even though personally I feel like it's a bug, since the non blocking writer can be combined with layers that output multiple lines for the same event. The module documentation of tracing_appender::non_blocking states : "When a line is written ..."; this implies that an event or span may not "span" multiple lines.

Crates

tracing_appender

Motivation

Pretty much all Layers I've dealt with have some sort of configuration to output an event or span in multiple lines (this is usually the "pretty" version).

Proposal

I have no idea how to implement this.

The new solution should reliably fully write an event or span even if it spans multiple lines before processing the next event or span.

Alternatives

From the tests I've done wrapping a RollingFileAppender directly in a NonBlocking will result in weaved output (parts of some events are weaved with some other events). Wrapping a RollingFileAppender in a std::io::BufWriter and then in a NonBlocking seems to "fix" the problem, however I'm not confident that's the correct solution.

mateiandrei94 commented 4 months ago

I just figured out that it was my own fault, I had multiple NonBlocking objects writing to the same file