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
36 changes: 29 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,11 +561,22 @@ impl Level {
LOG_LEVEL_NAMES[*self as usize]
}

/// Iterate through all supported logging levels
/// Iterate through all supported logging levels.
///
/// The order of iteration is from more severe to less severe log messages
/// The order of iteration is from more severe to less severe log messages.
///
/// # Examples
///
/// ```
/// use log::Level;
///
/// let mut levels = Level::iter();
///
/// assert_eq!(Some(Level::Error), levels.next());
/// assert_eq!(Some(Level::Trace), levels.last());
/// ```
pub fn iter() -> impl Iterator<Item = Self> {
(1..).flat_map(Self::from_usize)
(1..6).map(|i| Self::from_usize(i).unwrap())
}
}

Expand Down Expand Up @@ -709,6 +720,7 @@ impl LevelFilter {
_ => None,
}
}

/// Returns the most verbose logging level filter.
#[inline]
pub fn max() -> LevelFilter {
Expand All @@ -730,11 +742,22 @@ impl LevelFilter {
LOG_LEVEL_NAMES[*self as usize]
}

/// Iterate through all supported filtering levels
/// Iterate through all supported filtering levels.
///
/// The order of iteration is from less to more verbose filtering
/// The order of iteration is from less to more verbose filtering.
///
/// # Examples
///
/// ```
/// use log::LevelFilter;
///
/// let mut levels = LevelFilter::iter();
///
/// assert_eq!(Some(LevelFilter::Off), levels.next());
/// assert_eq!(Some(LevelFilter::Trace), levels.last());
/// ```
pub fn iter() -> impl Iterator<Item = Self> {
(0..).flat_map(Self::from_usize)
(0..6).map(|i| Self::from_usize(i).unwrap())
}
}

Expand Down Expand Up @@ -929,7 +952,6 @@ impl<'a> Record<'a> {
///
/// # Examples
///
///
/// ```edition2018
/// use log::{Level, Record};
///
Expand Down