Level-label
Convert a Level into its uppercase display label. This helper is useful for formatting, diagnostics, and user-visible output that should mirror the built-in level names.
Interface
moonbit
pub fn Level::label(self : Level) -> String {}input
self : Level- Level value whose display label should be returned.
output
String- Uppercase label such asTRACE,DEBUG,INFO,WARN, orERROR.
Explanation
Detailed rules explaining key parameters and behaviors
- The returned strings are uppercase built-in labels.
- This helper is intended for readable output and formatter logic.
- It is separate from
priority(), which is for numeric ordering. - The label reflects the enum variant directly and does not depend on any logger configuration.
How to Use
Here are some specific examples provided.
When Show A Level In Custom Output
When a callback or formatter wants a readable label:
moonbit
let label = Level::Warn.label()In this example, label becomes "WARN".
When Build Simple Human-readable Diagnostics
When direct console text should include the level name:
moonbit
let rec = Record::new(Level::Error, "dispatch failed")
println(rec.level.label())In this example, the output uses the built-in uppercase severity name.
Error Case
e.g.:
There is no failure path for valid
Levelvalues.If code needs numeric ordering rather than display text,
label()is the wrong helper.
Notes
Use this helper for presentation and diagnostics.
Prefer
priority()orenabled()for threshold logic.