Expand description
In-process log ring buffer + tracing layer.
init_logging installs a RingBufferLayer that captures recent log records
into a fixed-capacity ring buffer. The buffer is reachable through a global
singleton (global_ring) so REST handlers (e.g. /v1/system/log_tail) can
return diagnostics to clients without scraping log files.
Design notes:
- The buffer is bounded to
FEAGI_LOG_RING_BUFFER_CAPACITYrecords (default 2000) so memory usage stays predictable regardless of log volume. - Records are written non-blocking; the
tracinglayer never blocks the caller. - Reads clone the requested slice so callers do not hold the lock.
- Setting
FEAGI_LOG_RING_BUFFER_CAPACITY=0disables the layer entirely.
Structs§
- LogRecord
- One captured log record.
- LogRing
Buffer - Bounded ring buffer of log records (oldest are dropped when full).
- Ring
Buffer Layer - Tracing layer that pushes events into the global ring buffer.
Constants§
- CAPACITY_
ENV_ VAR - Environment variable name for capacity override (set to “0” to disable layer).
- DEFAULT_
CAPACITY - Default ring buffer capacity (records). Override via FEAGI_LOG_RING_BUFFER_CAPACITY.
Functions§
- capacity_
from_ env - Resolve the configured capacity from
FEAGI_LOG_RING_BUFFER_CAPACITY. Falls back toDEFAULT_CAPACITYwhen unset/invalid. - global_
ring - Returns the global ring buffer, if installed.
- install_
global_ ring - Install (once) the global ring buffer with the given capacity. Subsequent calls are no-ops and return the previously installed instance.