Merge pull request #459 from WaDelma/master

Expose logging levels
This commit is contained in:
Ashley Mannix 2021-11-15 10:43:45 +10:00 committed by GitHub
commit 2d3ecdfe86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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.
@ -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)]