tracing icon indicating copy to clipboard operation
tracing copied to clipboard

Make `tracing_subscriber::fmt::format::Writer::new` public

Open TmLev opened this issue 2 years ago • 0 comments

Feature Request

Crates

https://github.com/tokio-rs/tracing https://github.com/davidbarsky/tracing-tree

Motivation

I'm using tracing-tree, but it lacks timestamps. I opened an issue in tracing-tree about it and @davidbarsky suggested that FormatTime can be used as part of the implementation.

When trying to add support for it, I stumbled upon Writer which is needed for calling FormatTime::format_time. However, Writer has only one private constructor and cannot be instantiated outside the tracing-subscriber crate, which is quite limiting.

Proposal

Simple solution would be to make constructor entirely public, as suggested in TODO by @hawkw.

Alternatives

Another solution is to (maybe) add custom constructor that accepts String, for instance. This eliminates the need for making existing constructor public, but Writer::new(&'writer mut impl fmt::Write) seems to be more flexible.

TmLev avatar Jul 16 '22 16:07 TmLev