Open
Description
Some log
implementations support logger pipeline. For example, in logforth
you can write:
use log::LevelFilter;
use logforth::append;
logforth::builder()
.dispatch(|d| {
d.filter(LevelFilter::Error)
.append(append::Stderr::default())
})
.dispatch(|d| {
d.filter(LevelFilter::Info)
.append(append::Stdout::default())
})
.apply();
log::error!("Hello error!");
log::warn!("Hello warn!");
log::info!("Hello info!");
log::debug!("Hello debug!");
log::trace!("Hello trace!");
When I'm trying to add some complex appenders, for example, Kafka appender, it's natural to use a Kafka client lib. However, such a client lib may log inside also, which can result in an infinite recursive logging if such an appender is installed globally.
I did some investigation and how a possible solution, but would like to open this issue for discussion:
- Filter certain target in specific appender:
impl log::Log KafkaAppender {
fn log(&self, record: &Record) {
if record.target().start_with("rdkafka") { return; }
}
}
This is, however, both brittle and may filter logs from user code. I don't know how targets are defined and if we can reliably depend on that matches.
Metadata
Assignees
Labels
No labels