Description
Feature Request
Crates
tracing-subscriber
Motivation
I want to be able to make an extension trait on SubscriberBuilder
that offers builder-style configuration of my custom event/field formatters similarly to how it has methods to configure the default formatters. This would allow me to copy the current API so my crate will be familiar to users and easy to adopt. That means having a fmt() -> SubscriberBuilder
function along with adding methods to SubscriberBuilder<MyFields, MyFormat, _, _>
for configuration.
Proposal
SubscriberBuilder
should have methods that provide mutable access to the inner event/field formatters. This way I can configure my custom formatters. It would also allow for addition of niche configuration options on the default formatters that aren't worth adding wrapper methods to SubscriberBuilder
for.
These new methods can probably eschew the builder pattern in favor of just being mutable accessors (e.g. get_mut_event_format(&mut self) -> &mut E
) as they're most likely to be used by wrapper methods/functions, and any once-off use is expected to be niche.
Alternatives
#658 proposes making the event formatter own the field formatter. In this world, it's easier to configure them before giving them to the SubscriberBuilder
, though that approach still won't allow for copying the default API nor is it clear if this will even happen (and if so, when it will happen).