emit::level

Enum Level

Source
pub enum Level {
    Debug,
    Info,
    Warn,
    Error,
}
Expand description

A severity level for a diagnostic event.

If a crate::Event has a level associated with it, it can be pulled from its props:

match evt.props().pull::<emit::Level, _>(emit::well_known::KEY_LVL).unwrap_or_default() {
    emit::Level::Debug => {
        // The event is at the debug level
    }
    emit::Level::Info => {
        // The event is at the info level
    }
    emit::Level::Warn => {
        // The event is at the warn level
    }
    emit::Level::Error => {
        // The event is at the error level
    }
}

The default level is Level::Info.

§Parsing

Level has a permissive parser that will match partial and incomplete contents, ignoring case. So long as the start of the text is a submatch of the full level, and any trailing unmatched characters are not ASCII control characters, the level will parse.

For example, the following will all be parsed as Level::Info:

  • info
  • INFO
  • i
  • inf
  • information
  • INFO1
  • inf(13)

Note that any trailing data is lost when levels are parsed. That means, for example, that INFO3 and INFO4 will both parse to the same value, Level::Info, and will sort equivalently.

Variants§

§

Debug

The event is weakly informative.

This variant is equal to LVL_DEBUG.

§

Info

The event is informative.

This variant is equal to LVL_INFO.

§

Warn

The event is weakly erroneous.

This variant is equal to LVL_WARN.

§

Error

The event is erroneous.

This variant is equal to LVL_ERROR.

Implementations§

Source§

impl Level

Source

pub fn try_from_str(s: &str) -> Result<Self, ParseLevelError>

Try parse a level from a formatted representation.

Trait Implementations§

Source§

impl Clone for Level

Source§

fn clone(&self) -> Level

Returns a copy 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() -> Self

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 From<Level> for MinLevelFilter

Source§

fn from(min: Level) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Level

Source§

type Err = ParseLevelError

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

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl<'v> FromValue<'v> for Level

Source§

fn from_value(value: Value<'v>) -> Option<Self>

Perform the conversion.
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 ToValue for Level

Source§

fn to_value(&self) -> Value<'_>

Perform the conversion.
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 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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V