From e046be656e5b7119d8e0f9ea68ad82c0cffa1271 Mon Sep 17 00:00:00 2001 From: sgoudham Date: Sun, 3 Apr 2022 09:03:08 +0100 Subject: [PATCH] Ensure INFO logs are coloured white --- src/lib.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 54f5d70..f1dd7cb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -184,8 +184,20 @@ macro_rules! debug { #[macro_export] macro_rules! info { ($str:expr) => { + use std::io::Write; + use termcolor::WriteColor; + let now = chrono::Utc::now().format("%Y-%M-%dT%H:%M:%S%z"); - println!("{}", format!("[{} {}] {}", now, rall::Level::INFO, $str)); + let mut stream = termcolor::StandardStream::stdout(termcolor::ColorChoice::Always); + stream + .set_color( + termcolor::ColorSpec::new() + .set_fg(Some(termcolor::Color::White)) + .set_bold(true), + ) + .unwrap(); + writeln!(&mut stream, "[{} {}] {}", now, rall::Level::INFO, $str).unwrap(); + stream.reset().unwrap(); }; }