diff --git a/src/lib.rs b/src/lib.rs index bbfb1ed31..b4df51259 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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 { + (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 { + (0..).flat_map(Self::from_usize) + } } #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]