mirror of
https://github.com/Nanaloveyuki/BitLogger.git
synced 2026-05-30 15:42:25 +00:00
1.8 KiB
1.8 KiB
name, group, category, update-time, description, key-word
| name | group | category | update-time | description | key-word | ||||
|---|---|---|---|---|---|---|---|---|---|
| level-label | api | level | 20260512 | Convert a level into its uppercase display label. |
|
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
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:
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:
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.