Skip to content

Commit

Permalink
fix: Support all logger level case variants
Browse files Browse the repository at this point in the history
#4047 updated
parsing the logger level filter. It removed all case variants outside
fully uppercase (e.g. `INFO`) and the 1st character being upper case
(e.g. `Info`) this removed support for other previously supported
variants e.g. `info`. This commit re-introduces this support such that
all variants should again be supported.

Signed-off-by: Jonathan Woollett-Light <jcawl@amazon.co.uk>
  • Loading branch information
Jonathan Woollett-Light committed Nov 15, 2023
1 parent 7febde3 commit 20baf0c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/vmm/src/logger/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,13 @@ pub struct LevelFilterFromStrError(String);
impl FromStr for LevelFilter {
type Err = LevelFilterFromStrError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"Off" | "OFF" => Ok(Self::Off),
"Trace" | "TRACE" => Ok(Self::Trace),
"Debug" | "DEBUG" => Ok(Self::Debug),
"Info" | "INFO" => Ok(Self::Info),
"Warn" | "WARN" | "Warning" | "WARNING" => Ok(Self::Warn),
"Error" | "ERROR" => Ok(Self::Error),
match s.to_ascii_lowercase() {
"off" => Ok(Self::Off),
"trace" => Ok(Self::Trace),
"debug" => Ok(Self::Debug),
"info" => Ok(Self::Info),
"warn" | "warning" => Ok(Self::Warn),
"error" => Ok(Self::Error),
_ => Err(LevelFilterFromStrError(String::from(s))),
}
}
Expand Down

0 comments on commit 20baf0c

Please sign in to comment.