Skip to content

Commit 20baf0c

Browse files
author
Jonathan Woollett-Light
committed
fix: Support all logger level case variants
#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>
1 parent 7febde3 commit 20baf0c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/vmm/src/logger/logging.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,13 @@ pub struct LevelFilterFromStrError(String);
242242
impl FromStr for LevelFilter {
243243
type Err = LevelFilterFromStrError;
244244
fn from_str(s: &str) -> Result<Self, Self::Err> {
245-
match s {
246-
"Off" | "OFF" => Ok(Self::Off),
247-
"Trace" | "TRACE" => Ok(Self::Trace),
248-
"Debug" | "DEBUG" => Ok(Self::Debug),
249-
"Info" | "INFO" => Ok(Self::Info),
250-
"Warn" | "WARN" | "Warning" | "WARNING" => Ok(Self::Warn),
251-
"Error" | "ERROR" => Ok(Self::Error),
245+
match s.to_ascii_lowercase() {
246+
"off" => Ok(Self::Off),
247+
"trace" => Ok(Self::Trace),
248+
"debug" => Ok(Self::Debug),
249+
"info" => Ok(Self::Info),
250+
"warn" | "warning" => Ok(Self::Warn),
251+
"error" => Ok(Self::Error),
252252
_ => Err(LevelFilterFromStrError(String::from(s))),
253253
}
254254
}

0 commit comments

Comments
 (0)