Skip to main content

Module ring_layer

Module ring_layer 

Source
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_CAPACITY records (default 2000) so memory usage stays predictable regardless of log volume.
  • Records are written non-blocking; the tracing layer never blocks the caller.
  • Reads clone the requested slice so callers do not hold the lock.
  • Setting FEAGI_LOG_RING_BUFFER_CAPACITY=0 disables the layer entirely.

Structs§

LogRecord
One captured log record.
LogRingBuffer
Bounded ring buffer of log records (oldest are dropped when full).
RingBufferLayer
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 to DEFAULT_CAPACITY when 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.