diff --git a/src/main.rs b/src/main.rs index 908f1b8..8791547 100644 --- a/src/main.rs +++ b/src/main.rs @@ -195,7 +195,22 @@ fn main() { let logger = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")) .format_timestamp(None) - .format(|buf, record| writeln!(buf, "{}", record.args())) + .format(|buf, record| { + let message = record.args().to_string(); + match record.level() { + // Warnings and errors carry their level, colored for a + // terminal (bare when piped); the other levels keep the + // bare message, progress lines read better without a + // prefix + log::Level::Warn => { + writeln!(buf, "{}", ansi_wrap("33", &format!("WARN: {message}"))) + } + log::Level::Error => { + writeln!(buf, "{}", ansi_wrap("31", &format!("ERROR: {message}"))) + } + _ => writeln!(buf, "{message}"), + } + }) .build(); let multi = indicatif::MultiProgress::new(); LogWrapper::new(multi.clone(), logger).try_init().unwrap();