pub struct RequestLog { /* private fields */ }Expand description
An append-only, size-bounded record of every request the node served.
§Format
One JSON object per line — the same shape as ops.jsonl and
lag.jsonl, so the same tools read it — carrying format_version, the
wall-clock time, the authenticated user, the method, the redacted path,
the status, the response body size and the elapsed microseconds.
§Rotation
Size-bounded and single-generation. When the file passes
max_bytes it is renamed to <path>.1, replacing any previous .1,
and a fresh file is started. Disk is therefore bounded at roughly twice
max_bytes with no timer, no cron entry and no external logrotate — a
node that runs unattended for a year cannot fill its disk with this.
The cost of that simplicity is stated plainly: exactly two generations
are kept, so an operator who needs deeper history copies the file out
on their own schedule.
§Durability
One unbuffered write_all per request, no fsync. An incident log
that loses its tail to a buffer is worthless, and an fsync per
request would put a disk round-trip in every response path — this is an
observation, not the durable record.
Implementations§
Source§impl RequestLog
impl RequestLog
Sourcepub fn open(path: PathBuf, max_bytes: u64) -> Result<Self>
pub fn open(path: PathBuf, max_bytes: u64) -> Result<Self>
Opens path for append, creating it, and rotates at max_bytes.
§Errors
Propagates the failure to open the file. This is fatal at startup by design: an operator who asked for a request log and did not get one should find out before the node starts serving, not from the absence of evidence during an incident.