use colored::Colorize;
use log::{Level, LevelFilter, Metadata, Record};
pub struct MinimalLogger;
impl log::Log for MinimalLogger {
fn enabled(&self, _metadata: &Metadata) -> bool {
true
}
fn log(&self, record: &Record) {
if record.level() == Level::Info && record.target().starts_with("commitlog") {
return;
}
let level_string = match record.level() {
Level::Error => record.level().to_string().red(),
Level::Warn => record.level().to_string().yellow(),
Level::Info => record.level().to_string().cyan(),
Level::Debug => record.level().to_string().purple(),
Level::Trace => record.level().to_string().normal(),
};
if record.level() > LevelFilter::Error {
println!("{level_string:<5} {}", record.args());
} else {
eprintln!("{level_string:<5} {}", record.args());
}
}
fn flush(&self) {}
}