Skip to content

Commit

Permalink
Merge pull request #69 from etemesi254/main
Browse files Browse the repository at this point in the history
Ensure log levels are appropriately padded even on coloured outputs.
  • Loading branch information
borntyping committed Oct 19, 2022
2 parents 29af880 + 1002755 commit 1ed54e3
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/lib.rs
Expand Up @@ -375,19 +375,18 @@ impl Log for SimpleLogger {
{
if self.colors {
match record.level() {
Level::Error => record.level().to_string().red().to_string(),
Level::Warn => record.level().to_string().yellow().to_string(),
Level::Info => record.level().to_string().cyan().to_string(),
Level::Debug => record.level().to_string().purple().to_string(),
Level::Trace => record.level().to_string().normal().to_string(),
}
Level::Error => format!("{:<5}",record.level().to_string()).red().to_string(),
Level::Warn => format!("{:<5}",record.level().to_string()).yellow().to_string(),
Level::Info => format!("{:<5}",record.level().to_string()).cyan().to_string(),
Level::Debug => format!("{:<5}",record.level().to_string()).purple().to_string(),
Level::Trace => format!("{:<5}",record.level().to_string()).normal().to_string(), }
} else {
record.level().to_string()
format!("{:<5}", record.level().to_string())
}
}
#[cfg(not(feature = "colored"))]
{
record.level().to_string()
format!("{:<5}", record.level().to_string())
}
};

Expand Down Expand Up @@ -443,7 +442,7 @@ impl Log for SimpleLogger {
};

let message = format!(
"{}{:<5} [{}{}] {}",
"{}{} [{}{}] {}",
timestamp,
level_string,
target,
Expand Down

0 comments on commit 1ed54e3

Please sign in to comment.