Open lcmgh opened 2 months ago
Hmm this is kind of a hacky solution, but:
tracing_subscriber::registry()
.with(tracing_subscriber::fmt::layer())
.with(filter_fn(|meta| {
meta.fields().field("log.target").is_none()
}))
.init();
log::debug!("this is a log line");
tracing::debug!("this is a tracing line");
log-events do have some metadata that distinguish them: log.target
, log.module_path
, log.file
, log.line
. But this is not really a fool-proof solution. Maybe we could add a specific field like: source: log
or something?
Feature Request
Crates
Motivation
When using
tracing
withtracing-log
to convertlog
crate entries to tracing events I'd like to exclude such events from being exported to my tracing backend. For filtering one can for instance utilize Metadata but I can't find any option to tell whether an event was sourced from alog
entry. So I currently must export all my logs to the tracing backend which is what I want to prevent.Proposal
log
so it can be filtered later onAlternatives
I found
tracing
quite useful as primary logger due to it's layer system. Maybe I am using the wrong tools here and should rather take a regular logger and then convert tracing events to logs?