Skip to main content

Module diag

Module diag 

Source
Expand description

Process-wide diagnostics: capture every WARN+ tracing event and panic.

Each one ends up in (a) the rolling log file, (b) a global ring buffer surfaced through MetricsSnapshot → the F12 panel and fmf stats, and (c) any registered sinks (the FFI forwards them as ENGINE_ERROR events to the UI). The layer responsible for the “don’t go silent” arm of “don’t crash / don’t hang / don’t go silent”.

Structs§

DiagLayer
Routes WARN/ERROR tracing events into the diagnostics ring + sinks. Events with target: "panic" are classified as panics.
ErrorEvent
One captured diagnostic event: the unit stored in the ring and fanned out to sinks.
FieldGrab 🔒
SinkGuard
Lifetime handle for a registered sink; dropping it unregisters the sink.

Enums§

Severity
Severity class of a captured diagnostic event, in ascending order.

Constants§

RING_CAP 🔒

Statics§

LOG_GUARD 🔒
RING 🔒
SEQ 🔒
SINKS 🔒
SINK_IDS 🔒
START 🔒

Functions§

error_chain
Full error cause chain as one line.
init_diag
The one diagnostics bootstrap: file/stderr logging + panic capture + diag-ring wiring, idempotent — FFI fmf_engine_create, the service entry points and the CLI all call exactly this (ADR-0018).
init_logging
Initialize process-wide logging once.
install_panic_hook
Route every panic (any thread) through tracing with a backtrace, so it reaches the log file, the ring and the UI. Idempotent.
recent_errors
Snapshot of the diagnostics ring (oldest first), capped at the ring size.
record
Record one diagnostic event (ring + sinks). Normally reached via the tracing layer rather than called directly.
register_sink
Register a fan-out target for new error events; dropping the guard unregisters it (the FFI ties this to the engine handle’s lifetime).
resolve_log_dir
Resolves the engine log directory.

Type Aliases§

Sink 🔒