Level
Level is the public severity enum used across records, filters, and logger threshold checks. It is a direct alias to the core level type, so the same five built-in variants are shared everywhere the public API accepts or returns a level.
Interface
pub type Level = @core.Leveloutput
Level- Public severity enum with the variantsTrace,Debug,Info,Warn, andError.
Explanation
Detailed rules explaining key parameters and behaviors
- This is a type alias, not a wrapper or a separate enum.
- The built-in variants are
Level::Trace,Level::Debug,Level::Info,Level::Warn, andLevel::Error. Levelis used byRecord::new(...), logger threshold APIs, predicate helpers, and config-driven builders.- Ordering and display behavior come from the same underlying type, so helpers such as
priority(),label(), andenabled(...)work on this alias unchanged.
How to Use
Here are some specific examples provided.
When Need A Severity For New Records
When a record should be created with a concrete severity:
let rec = Record::new(Level::Warn, "disk almost full")In this example, the record uses the public Level alias directly.
When Need A Threshold For Logger Filtering
When a logger should only accept records at or above one severity:
let logger = Logger::new(console_sink()).with_min_level(Level::Info)In this example, the same public level enum is reused as the threshold value.
Error Case
e.g.:
Levelitself does not have a runtime failure mode.If external config text names an unsupported level string, parsing fails through
ConfigErrorinstead of producing a fallback level.
Notes
Use
label()for display text andpriority()orenabled(...)for threshold logic.This alias keeps sync APIs, async APIs, and config builders on the same severity vocabulary.