#[repr(u16)]
pub enum Level {
Critical,
Error,
Warn,
Info,
Debug,
Trace,
}
Expand description
An enum representing log levels.
Typical usage includes: specifying the Level
of log!
, and comparing a
Level
to a LevelFilter
through LevelFilter::compare
.
Note
Users should never convert variants of this enum to integers for persistent
storage (e.g., configuration files), using Level::as_str
instead,
because integers corresponding to variants may change in the future.
Do not do this:
let level: Level = /* ... */
let value: usize = level as usize;
save_to_config_file(value);
Instead:
let level: Level = /* ... */
let value: &'static str = level.as_str();
save_to_config_file(value);
Examples
use spdlog::prelude::*;
log!(Level::Info, "hello, world");
Variants§
Critical
Designates critical errors.
Error
Designates very serious errors.
Warn
Designates hazardous situations.
Info
Designates useful information.
Debug
Designates lower priority information.
Trace
Designates very low priority, often extremely verbose, information.
Implementations§
source§impl Level
impl Level
sourcepub const fn most_severe() -> Level
pub const fn most_severe() -> Level
Returns the most severe logging level.
sourcepub const fn most_verbose() -> Level
pub const fn most_verbose() -> Level
Returns the most verbose logging level.
sourcepub fn as_str(&self) -> &'static str
pub fn as_str(&self) -> &'static str
Returns the string representation of the Level
.
This returns the same string as the fmt::Display
implementation.
sourcepub fn iter() -> impl Iterator<Item = Self>
pub fn iter() -> impl Iterator<Item = Self>
Iterate through all supported logging levels.
The order of iteration is from more severe to more verbose.
Examples
use spdlog::Level;
let mut levels = Level::iter();
assert_eq!(Some(Level::Critical), levels.next());
assert_eq!(Some(Level::Trace), levels.last());