use flexi_logger::{writers::FileLogWriter, FileSpec, LogSpecification, Logger};
use log::{error, trace, LevelFilter};
fn main() {
let writer = FileLogWriter::builder(FileSpec::default())
.max_level(LevelFilter::Warn)
.try_build()
.unwrap();
let _handle = Logger::with(LogSpecification::trace())
.log_to_writer(Box::new(writer))
.start()
.unwrap();
trace!("this should not be written to the file");
error!("this should be written to the file");
}
I would expect that only the error! message gets written to the log file, but both are written when I run this.
It looks like FileLogWriter never checks that a record is above its own max_level before writing it.
In this example code:
I would expect that only the
error!
message gets written to the log file, but both are written when I run this. It looks likeFileLogWriter
never checks that a record is above its ownmax_level
before writing it.I'd be happy to PR a fix for this if you'd like.