Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only style the level label #59

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading