Skip to content

Recent History Capture

Eduard Mishkurov edited this page Jun 10, 2026 · 1 revision

Recent-History Capture

Recent-history capture means keeping the last N formatted log records in memory and dumping them only when they become useful, for example after an error or failed request.

This is similar in purpose to “backtrace logging” in some other logging libraries, but it is not a stack trace. It does not capture call stacks. It captures recent log records.


RingBufferBackend

logme implements this storage primitive through RingBufferBackend.

RingBufferBackend keeps only the last configured number of formatted records. Old records are removed automatically when the limit is reached.

Example JSON backend configuration:

{
  "type": "RingBufferBackend",
  "max-items": 200
}

Example runtime command:

logmectl -p 9010 backend --channel net --add ring --max-items 200

The backend can later join its current records into a single string through the C++ API.


When to use it

Use recent-history capture when full verbose logging would be too noisy or too expensive to persist permanently, but the last few records would be valuable when a failure happens.

Typical scenarios:

  • request diagnostics
  • connection lifecycle diagnostics
  • unit tests that assert on emitted logs
  • temporary in-memory diagnostics for logmeweb or application-owned tools
  • storing the last few steps before an error without keeping the entire debug stream

Difference from BufferBackend

BufferBackend stores a continuous text buffer. Depending on policy, it can stop appending or delete oldest lines when it reaches a byte limit.

RingBufferBackend stores a fixed number of records. It is better for “last N events” diagnostics.


Policy note

Whether a record reaches RingBufferBackend is still controlled by the channel. If the channel rejects Debug records by level, the ring buffer will not see those records.

For independent per-destination levels, use separate channels and routing. logme currently treats the channel as the primary policy unit rather than adding hidden per-backend level checks.

See Feature Map and Routing.

Clone this wiki locally