Skip to main content

Level

Enum Level 

Source
#[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

LevelLinux ConstantUsage
ErrorKERN_ERRCritical errors requiring immediate attention
WarnKERN_WARNINGWarning conditions
InfoKERN_INFOInformational messages
DebugKERN_DEBUGDebug-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

Source

pub const ALL: [Self; 5]

All log levels in order of severity.

Source

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");
Source

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 severe

Trait Implementations§

Source§

impl Clone for Level

Source§

fn clone(&self) -> Level

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Level

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Level

Source§

fn default() -> Level

Returns the “default value” for a type. Read more
Source§

impl Display for Level

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromStr for Level

Source§

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());
Source§

type Err = ParseLevelError

The associated error which can be returned from parsing.
Source§

impl Hash for Level

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Level

Source§

fn cmp(&self, other: &Level) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Level

Source§

fn eq(&self, other: &Level) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Level

Source§

fn partial_cmp(&self, other: &Level) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for Level

Source§

impl Eq for Level

Source§

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 UnsafeUnpin for Level

§

impl UnwindSafe for Level

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.