Skip to main content

Module logging

Module logging 

Source
Expand description

Process-wide logging: the subscriber main installs, with a reloadable slot for the OTLP log-export layer.

The subscriber must exist before any subcommand logs, but the [observability] config that decides whether daemon logs also export over OTLP is only read later (by the daemon, after Config::load). Bridging that gap is what the reload slot is for: init installs the fmt layer plus an empty slot and parks the reload handle in a static; install_otel_layer fills the slot once the daemon has built its exporter. Everything stays on stderr - lev agent-client uses stdout as its JSON-RPC channel, and a stray log line there would corrupt the stream a host is parsing.

Functions§

init
Install the process-wide subscriber: fmt → stderr at info (debug when verbose), plus the empty reloadable OTLP slot.
install_otel_layer
Fill the reload slot with the daemon’s OTLP log-export layer. Returns whether the layer was installed - false when init hasn’t run (a library consumer with its own subscriber) or the slot is gone.