Expand description
Structured logging façade over tracing + tracing-subscriber.
Entry point for the red binary and any embedder that wants RedDB
to manage logging on its behalf. Sets up two layers:
- stderr — pretty (TTY) or JSON (piped/CI) formatted logs
- file — optional daily-rotating file in
log_dir, non-blocking writer backed bytracing-appender
A background janitor purges rotated files older than
rotation_keep_days every hour.
The returned Option<TelemetryGuard> must live for the process
lifetime — dropping it flushes the non-blocking buffer so no log
lines are lost on graceful shutdown.
Modules§
- admin_
intent_ log - Intent log for long-running admin operations.
- janitor
- Log-file retention janitor.
- operator_
event - Operator-grade event bus for high-severity system conditions.
- operator_
event_ router - Config-driven per-variant routing for
OperatorEvent. - slow_
query_ logger - Dedicated slow-query sink — writes structured JSON lines to
red-slow.log. - span
- Span helpers that pull connection / transaction / tenant / auth
context out of the runtime thread-locals and attach them to a
tracing::Span. Any log emitted while the span is entered picks up these fields automatically — the caller never has to passconn_id/xid/tenantas parameters down through the call graph.
Structs§
- Telemetry
Config - Telemetry
Guard - Opaque handle that keeps the non-blocking log writers alive. Drop at process exit to flush the buffered records for stderr AND the rotating file sink. Both writers run on their own dedicated background threads — the hot path only pushes onto an MPSC channel, never touches stdio syscalls directly.
Enums§
- LogFormat
- Stdio / file output format.
Prettyrenders human-readable coloured lines;Jsonemits NDJSON suitable for Loki / ELK / Datadog.
Functions§
- init
- Install the global
tracingsubscriber. Idempotent: if another subscriber is already registered (e.g. an embedder set up its own), we silently returnNoneand let the caller proceed.