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:
infoINFOiinfinformationINFO1inf(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
impl Level
Sourcepub fn try_from_str(s: &str) -> Result<Self, ParseLevelError>
pub fn try_from_str(s: &str) -> Result<Self, ParseLevelError>
Try parse a level from a formatted representation.