level_filtering/
level-filtering.rs1use traccia::{error, fatal, info, FileMode, LogLevel};
2
3fn main() {
4 traccia::init_with_config(traccia::Config {
5 level: LogLevel::Trace,
6 targets: vec![
7 Box::new(traccia::Console::new()),
8 Box::new(
9 traccia::File::new("./.logs/latest.log", FileMode::Truncate)
10 .expect("Failed to open file.")
11 .filtered(LogLevel::Fatal),
12 ),
13 ],
14 ..Default::default()
15 });
16
17 info!("This will not be written to latest.log, but will be printed to console.");
18 error!("It will write fatal messages only!");
19 fatal!("Like this :(");
20}