Sane extra defaults for tracing_subscriber?

Hey!

I'm using tracing and tracing_subscriber. I see that both are extensible with user-defined implementations.

Only my problem is that there's only 1 default subscriber and very limited options for modifying it. An example is that I can disable displaying time in logs, but to change the way time gets formatted I'd need to reimplement the whole EventFormatter, specifying how everything gets formatted.

Is there some library that provides Layers/EventFormatters/Subscribers in various flavors, defined to be used with tracing_subscriber. With things like modifying formatting of just one portion of the log event, logging to stderr, etc?

You have the fmt::SubscriberBuilder::with_timer method to override how your timestamps should be formatted. See i.e. fmt::time::UtcTime::new for how to construct a timer that formats your timestamps how you like it.

As to additional Subscriber implementations, I don't know any other crates. But you could check out this list of crates from the greater tracing ecosystem and see if one provides Subscribers more to your liking.

1 Like

You have the fmt::SubscriberBuilder::with_timer method to override how your timestamps should be formatted.

I see, thanks! I sort of assumed it takes just a boolean as some of the other simmilar methods.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.