Skip to content

Commit

Permalink
Only style the level label
Browse files Browse the repository at this point in the history
  • Loading branch information
delehef authored and cardoe committed Jan 31, 2024
1 parent c4c36ea commit 85550fb
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,10 @@ impl Log for StdErrLog {
let mut writer = io::LineWriter::new(writer.lock());
let color = match record.metadata().level() {
Level::Error => Color::Red,
Level::Warn => Color::Magenta,
Level::Info => Color::Yellow,
Level::Warn => Color::Yellow,
Level::Info => Color::Blue,
Level::Debug => Color::Cyan,
Level::Trace => Color::Blue,
Level::Trace => Color::Magenta,
};
{
// A failure here indicates the stream closed. Do not panic.
Expand Down Expand Up @@ -356,13 +356,14 @@ impl Log for StdErrLog {
Timestamp::Off => {}
}
if self.show_level {
let _ = write!(writer, "{} - ", record.level());
let _ = write!(writer, "{} ", record.level());
}
let _ = writeln!(writer, "{}", record.args());
writer.flush().ok();
{
// A failure here indicates the stream closed. Do not panic.
writer.get_mut().reset().ok();
}
let _ = writeln!(writer, "{}", record.args());
}

fn flush(&self) {
Expand Down

0 comments on commit 85550fb

Please sign in to comment.