tracing: When creating my own FormatEvent type, I have to duplicate a lot of code
Feature Request
Crates
tracing-subscriber
Motivation
I’m trying to customize the log lines in the terminal. For that I need to write my own FormatEvent.
I copy-pasted the code of the one provided by tracing-subsriber called Format. But I had to duplicate a lot of other objects before being able to make it useful: FmtLevel, FmtThreadName, FmtCtx, even format::time::write()
Proposal
Not sure. Maybe make some common things pub?
Alternatives
Not sure either.
cc @davidbarsky
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 2
- Comments: 19 (10 by maintainers)
I understand the frustration, but I’d encourage a more constructive tone. The maintainers are offering this crate for free, and respectful feedback helps everyone. It’s not about the technical point — which is valid — but how it’s delivered. There’s always a way to express concerns without discouraging those doing the work.
Being unable to write custom formatters without copying a ton of code, forking the crate, or suffering the performance impact from serializing and reserializing JSON every time we write has, singlehandedly, made this one of the most frustrating logging libraries I’ve ever had the displeasure of using. Please fix this.
I think the issue that would help here is #819. We’re definitely interested in adding
serdesupport in the new value system fortracing0.2.I’m a little wary of making too much of the current interface
pub— then, it becomes a breaking change to remove it in the future. Rather than makingFmtContextpublic and committing to maintaining it forever, I’d prefer to refactor the API so that theFmtContexttype isn’t necessary (https://github.com/tokio-rs/tracing/issues/658).