Expand description
In-crate structured-logging facade.
The statusline is a single-shot, stderr-free-by-default process; a
full tracing/log stack would bloat the binary for a narrow
diagnostic surface. This module exposes level-gated emission
through two macros, [lsm_warn!] and [lsm_debug!], controlled by
the LINESMITH_LOG env var.
Default level is Level::Warn so genuine drops (cache-write
failures, lock-write failures) surface without opt-in. Silent
[Ok(None)] hide paths in rate-limit segments log at
Level::Debug and require LINESMITH_LOG=debug to appear.
Structural failures that always warrant a user-visible signal
(segment render panics, fatal plugin init errors) emit through
[lsm_error!], which bypasses the level gate. LINESMITH_LOG=off
quiets chatter; it is not a silence-all-signals switch, because a
broken statusline needs a stderr line the user can grep. Scripts
that want absolute silence can 2>/dev/null.
Output format: linesmith [<level>]: <message>. A future doctor
command can buffer and reformat the same emissions.
Not a general-purpose logger: no filtering by target, no structured fields, no sink swap. Add those when a call site needs them.
Enums§
- Level
- Logger severity. Variants are ordered
Off < Warn < Debugso a call fires when its own level is<=the configured level.
Constants§
Functions§
- apply
- Apply
raw(the snapshottedLINESMITH_LOGvalue,Noneif unset) to the process-wide level. On an unrecognized value the logger resets to [DEFAULT_LEVEL] and writes one line towarn_sink; the driver threads the injected CLI stderr through so tests and embedders don’t see ambient stderr pollution. - emit
- Emit
msgatlvlwhen the configured level allows. A broken stderr (closed pipe, full disk) drops the write silently — the statusline has no recovery path and panicking would nuke an otherwise-good render. - emit_
error - Emit a structural-failure diagnostic. Bypasses the level gate:
even
LINESMITH_LOG=offdoes not suppress it, because the only things that reach this function are render failures a user has no other way of seeing. - is_
enabled truewhenat_leastor a more verbose level is active. A call fires when its own level is<=the currently configured level.- level
- set_
level - Override the process-wide level. Exposed for tests and embedders that want to pick a level without touching the env.