#[repr(u8)]pub enum Level {
Error = 0,
Warn = 1,
Info = 2,
Debug = 3,
Trace = 4,
}Expand description
Log level for kernel messages.
Levels are ordered by severity, with Error being the most severe
and Trace being the most verbose. This ordering allows filtering:
if a logger is configured for Info level, it will log Error,
Warn, and Info messages, but not Debug or Trace.
§Linux Equivalent
| Level | Linux Constant | Usage |
|---|---|---|
| Error | KERN_ERR | Critical errors requiring immediate attention |
| Warn | KERN_WARNING | Warning conditions |
| Info | KERN_INFO | Informational messages |
| Debug | KERN_DEBUG | Debug-level messages |
| Trace | (custom) | Most verbose tracing |
§Example
use reovim_kernel::api::v1::*;
use std::str::FromStr;
let level = Level::Info;
assert!(level <= Level::Debug); // Info is less verbose than Debug
assert!(level >= Level::Error); // Info is more verbose than Error
// Convert to/from string
assert_eq!(Level::Error.as_str(), "ERROR");
assert_eq!(Level::from_str("warn"), Ok(Level::Warn));Variants§
Error = 0
Critical errors requiring immediate attention.
Use for conditions that prevent normal operation.
Linux equivalent: KERN_ERR
Warn = 1
Warning conditions.
Use for potentially harmful situations that don’t prevent operation.
Linux equivalent: KERN_WARNING
Info = 2
Informational messages.
Use for general operational messages.
Linux equivalent: KERN_INFO
Debug = 3
Debug-level messages.
Use for detailed diagnostic information during development.
Linux equivalent: KERN_DEBUG
Trace = 4
Trace-level messages.
Most verbose level, for detailed tracing of execution flow.
Implementations§
Source§impl Level
impl Level
Sourcepub const fn as_str(&self) -> &'static str
pub const fn as_str(&self) -> &'static str
Returns the string representation of this level.
§Example
use reovim_kernel::api::v1::*;
assert_eq!(Level::Error.as_str(), "ERROR");
assert_eq!(Level::Warn.as_str(), "WARN");
assert_eq!(Level::Info.as_str(), "INFO");
assert_eq!(Level::Debug.as_str(), "DEBUG");
assert_eq!(Level::Trace.as_str(), "TRACE");Sourcepub const fn is_at_least(&self, other: Self) -> bool
pub const fn is_at_least(&self, other: Self) -> bool
Check if this level is at least as severe as the given level.
§Example
use reovim_kernel::api::v1::*;
assert!(Level::Error.is_at_least(Level::Info)); // Error is more severe
assert!(Level::Info.is_at_least(Level::Info)); // Same level
assert!(!Level::Debug.is_at_least(Level::Info)); // Debug is less severeTrait Implementations§
Source§impl FromStr for Level
impl FromStr for Level
Source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Parses a level from a string (case-insensitive).
§Example
use reovim_kernel::api::v1::*;
use std::str::FromStr;
assert_eq!(Level::from_str("error"), Ok(Level::Error));
assert_eq!(Level::from_str("WARN"), Ok(Level::Warn));
assert_eq!(Level::from_str("Info"), Ok(Level::Info));
assert!(Level::from_str("unknown").is_err());