#[repr(u16)]pub enum Level {
Critical = 0,
Error = 1,
Warn = 2,
Info = 3,
Debug = 4,
Trace = 5,
}
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 = 0
Designates critical errors.
Error = 1
Designates very serious errors.
Warn = 2
Designates hazardous situations.
Info = 3
Designates useful information.
Debug = 4
Designates lower priority information.
Trace = 5
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());