#[repr(u16)]pub enum Level {
Critical = 0,
Error = 1,
Warn = 2,
Info = 3,
Debug = 4,
Trace = 5,
}
Expand description
Represents log levels.
Typical usage:
- specifying the
level
parameter of macrolog!
; - comparing a
Level
to aLevelFilter
throughLevelFilter::test
.
§Note
Users should never cast 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 value = level as u32; // Never do numeric casting!
save_to_config_file(value);
Instead:
let value = 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.
This returns the same string as the fmt::Display
implementation.
Sourcepub fn iter() -> impl Iterator<Item = Self>
pub fn iter() -> impl Iterator<Item = Self>
Iterates through all 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());