Skip to main content

LogSink

Trait LogSink 

Source
pub trait LogSink: Send + Sync {
    // Required methods
    fn emit(&self, lvl: Level, msg: &str);
    fn emit_error(&self, msg: &str);
}
Expand description

Pluggable destination for diagnostic emissions. The default StderrSink preserves the linesmith [<level>]: <msg> format external scripts grep for; the TUI swaps in a CapturedSink for the duration of the alt-screen so macro emissions land in the warnings panel instead of corrupting the painted frame.

&self (not &mut self) so a sink instance can be shared via Arc<dyn LogSink>. The Send + Sync bound is what Arc<dyn _> requires; today only the render thread emits, but the bound keeps the door open for future background plugin emitters without breaking the public surface. Concurrent emit/swap is not yet supported — a swap that races with an in-flight current_sink() clone can land an emission on the just- orphaned sink. See lsm-wyph follow-ups for the work to close that.

Required Methods§

Source

fn emit(&self, lvl: Level, msg: &str)

Emit a level-gated diagnostic. The caller has already confirmed the level is enabled — the sink writes unconditionally. Implementations defensively no-op on Level::Off rather than relying on the caller; the macros never pass Off, but emit() is pub.

Source

fn emit_error(&self, msg: &str)

Emit a structural-failure diagnostic. Always fires regardless of the configured level — LINESMITH_LOG=off users still see “the statusline broke” because there’s no other channel.

Implementors§