#[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
levelparameter of macrolog!; - comparing a
Levelto aLevelFilterthroughLevelFilter::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.
Examples found in repository?
46 fn format(
47 &self,
48 record: &Record,
49 dest: &mut StringBuf,
50 ctx: &mut FormatterContext,
51 ) -> spdlog::Result<()> {
52 let style_range_begin = dest.len();
53
54 dest.write_str(&record.level().as_str().to_ascii_uppercase())
55 .map_err(spdlog::Error::FormatRecord)?;
56
57 let style_range_end = dest.len();
58
59 writeln!(dest, " {}", record.payload()).map_err(spdlog::Error::FormatRecord)?;
60
61 ctx.set_style_range(Some(style_range_begin..style_range_end));
62 Ok(())
63 }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());Trait Implementations§
impl Copy for Level
impl Eq for Level
impl NoUninit for Level
impl StructuralPartialEq for Level
Auto Trait Implementations§
impl Freeze for Level
impl RefUnwindSafe for Level
impl Send for Level
impl Sync for Level
impl Unpin for Level
impl UnwindSafe for Level
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)