Skip to content

Commit

Permalink
Merge pull request #459 from WaDelma/master
Browse files Browse the repository at this point in the history
Expose logging levels
  • Loading branch information
KodrAus committed Nov 15, 2021
2 parents ed0dacc + 05532fa commit 2d3ecdf
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,13 @@ impl Level {
pub fn as_str(&self) -> &'static str {
LOG_LEVEL_NAMES[*self as usize]
}

/// Iterate through all supported logging levels
///
/// The order of iteration is from more severe to less severe log messages
pub fn iter() -> impl Iterator<Item = Self> {
(1..).flat_map(Self::from_usize)
}
}

/// An enum representing the available verbosity level filters of the logger.
Expand Down Expand Up @@ -722,6 +729,13 @@ impl LevelFilter {
pub fn as_str(&self) -> &'static str {
LOG_LEVEL_NAMES[*self as usize]
}

/// Iterate through all supported filtering levels
///
/// The order of iteration is from less to more verbose filtering
pub fn iter() -> impl Iterator<Item = Self> {
(0..).flat_map(Self::from_usize)
}
}

#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
Expand Down

0 comments on commit 2d3ecdf

Please sign in to comment.