Open gdesmott opened 3 years ago
It should be fairly straightforward to add a new toggle to the Format
type, here
https://github.com/tokio-rs/tracing/blob/2f6fcb0fabff541d14b0fe3a5211b8f472fec4cb/tracing-subscriber/src/fmt/format/mod.rs#L251-L260
and extend the existing formatters to display the module path when configured to do so. For example, we would add something similar to this in the default formatter:
https://github.com/tokio-rs/tracing/blob/2f6fcb0fabff541d14b0fe3a5211b8f472fec4cb/tracing-subscriber/src/fmt/format/mod.rs#L606-L608
except we would display the value of meta.module_path()
rather than meta.target()
.
If you're interested in working on a PR to add this, I'm happy to answer any questions; otherwise, I'll see about adding it when I have some spare time.
One minor design question that does come to mind, though: for most events and spans emitted through the tracing
macros, the the target
and module_path
metadata values will be the same, since the target defaults to the module path when not explicitly overridden. If the formatter is configured to display both targets and module paths, we may want to skip printing both when these values are equal; otherwise, the majority of events would just print the module path twice.
Feature Request
Crates
tracing_subscriber
Motivation
tracing-gstreamer populate the module path with the C function name from the C API. I'd like to display it in my log but it looks like
tracing_subscriber
does not have API to do so.