Skip to content

Commit

Permalink
refactor: Shift numeric level to be 0 based
Browse files Browse the repository at this point in the history
  • Loading branch information
joshka authored and epage committed Sep 26, 2024
1 parent 4c96f55 commit 02ddbef
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,23 +133,23 @@ impl<L: LogLevel> Verbosity<L> {

fn level_value(level: Option<Level>) -> i8 {
match level {
None => -1,
Some(Level::Error) => 0,
Some(Level::Warn) => 1,
Some(Level::Info) => 2,
Some(Level::Debug) => 3,
Some(Level::Trace) => 4,
None => 0,
Some(Level::Error) => 1,
Some(Level::Warn) => 2,
Some(Level::Info) => 3,
Some(Level::Debug) => 4,
Some(Level::Trace) => 5,
}
}

fn level_enum(verbosity: i8) -> Option<Level> {
match verbosity {
i8::MIN..=-1 => None,
0 => Some(Level::Error),
1 => Some(Level::Warn),
2 => Some(Level::Info),
3 => Some(Level::Debug),
4..=i8::MAX => Some(Level::Trace),
i8::MIN..=0 => None,
1 => Some(Level::Error),
2 => Some(Level::Warn),
3 => Some(Level::Info),
4 => Some(Level::Debug),
5..=i8::MAX => Some(Level::Trace),
}
}

Expand Down

0 comments on commit 02ddbef

Please sign in to comment.