Enum Level

enum Level

An enum representing the available verbosity levels of the logger.

Typical usage includes: checking if a certain Level is enabled with log_enabled!, specifying the Level of log!, and comparing a Level directly to a LevelFilter.

Variants

Error

The "error" level.

Designates very serious errors.

Warn

The "warn" level.

Designates hazardous situations.

Info

The "info" level.

Designates useful information.

Debug

The "debug" level.

Designates lower priority information.

Trace

The "trace" level.

Designates very low priority, often extremely verbose, information.

Implementations

impl Level

fn max() -> Level

Returns the most verbose logging level.

fn to_level_filter(self: &Self) -> LevelFilter

Converts the Level to the equivalent LevelFilter.

fn as_str(self: &Self) -> &'static str

Returns the string representation of the Level.

This returns the same string as the fmt::Display implementation.

fn iter() -> impl Iterator<Item = Self>

Iterate through all supported logging levels.

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());
fn increment_severity(self: &Self) -> Self

Get the next-highest Level from this one.

If the current Level is at the highest level, the returned Level will be the same as the current one.

Examples

use log::Level;

let level = Level::Info;

assert_eq!(Level::Debug, level.increment_severity());
assert_eq!(Level::Trace, level.increment_severity().increment_severity());
assert_eq!(Level::Trace, level.increment_severity().increment_severity().increment_severity()); // max level
fn decrement_severity(self: &Self) -> Self

Get the next-lowest Level from this one.

If the current Level is at the lowest level, the returned Level will be the same as the current one.

Examples

use log::Level;

let level = Level::Info;

assert_eq!(Level::Warn, level.decrement_severity());
assert_eq!(Level::Error, level.decrement_severity().decrement_severity());
assert_eq!(Level::Error, level.decrement_severity().decrement_severity().decrement_severity()); // min level

impl Clone for Level

fn clone(self: &Self) -> Level

impl Copy for Level

impl Debug for Level

fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<'_>) -> $crate::fmt::Result

impl Display for Level

fn fmt(self: &Self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result

impl Eq for Level

impl Freeze for Level

impl FromStr for Level

fn from_str(level: &str) -> Result<Level, <Self as >::Err>

impl Hash for Level

fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H)

impl Ord for Level

fn cmp(self: &Self, other: &Level) -> $crate::cmp::Ordering

impl PartialEq for Level

fn eq(self: &Self, other: &LevelFilter) -> bool

impl PartialEq for Level

fn eq(self: &Self, other: &Level) -> bool

impl PartialOrd for Level

fn partial_cmp(self: &Self, other: &Level) -> $crate::option::Option<$crate::cmp::Ordering>

impl PartialOrd for Level

fn partial_cmp(self: &Self, other: &LevelFilter) -> Option<cmp::Ordering>

impl RefUnwindSafe for Level

impl Send for Level

impl Serialize for crate::Level

fn serialize<S>(self: &Self, serializer: S) -> Result<<S as >::Ok, <S as >::Error>
where
    S: Serializer

impl StructuralPartialEq for Level

impl Sync for Level

impl Unpin for Level

impl UnwindSafe for Level

impl<'de> Deserialize for crate::Level

fn deserialize<D>(deserializer: D) -> Result<Self, <D as >::Error>
where
    D: Deserializer<'de>

impl<T> Any for Level

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Level

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Level

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for Level

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> DeserializeOwned for Level

impl<T> From for Level

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Level

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T> ToString for Level

fn to_string(self: &Self) -> String

impl<T, U> Into for Level

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for Level

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for Level

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>