Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth documenting something about the order of these fields. Using from_usize we’re effectively returning them in priority order.

What do you think?

(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