pub struct AccessLog { /* private fields */ }Expand description
Buffered emitter. Per-handler call sites push entries via
AccessLog::record; a background task drains the buffer and writes
one S3 object per flush window.
Implementations§
Source§impl AccessLog
impl AccessLog
pub fn new(dest: AccessLogDest) -> Self
Sourcepub fn with_hmac_key(self, key: Arc<AuditHmacKey>) -> Self
pub fn with_hmac_key(self, key: Arc<AuditHmacKey>) -> Self
v0.5 #31: turn on tamper-evident HMAC chaining. Every emitted
line gets a trailing hex HMAC column, and each new batch file
starts with a # prev_file_tail=<hex> comment so the chain
extends across rotations. Without this builder, lines are
emitted exactly as before (back-compat with v0.4 #20 readers).
pub async fn record(&self, entry: AccessLogEntry)
Sourcepub fn spawn_flusher(&self, shutdown: Option<Arc<Notify>>) -> JoinHandle<()>
pub fn spawn_flusher(&self, shutdown: Option<Arc<Notify>>) -> JoinHandle<()>
Spawn the background flusher. Drains the buffer every
flush_every_secs (default 60) and appends to the per-hour file
in dest.dir. Returns the tokio JoinHandle so the caller can
abort on shutdown if needed.
v0.8.5 #81 (audit H-7): the optional shutdown notifier lets the
listener loop signal the flusher to drain the buffer one final
time and exit cleanly on SIGTERM / SIGINT — without this, the
detached task would keep ticking past the listener loop break and
the process would only stop because tokio drops the runtime out
from under it (any in-flight write would be torn at an arbitrary
boundary). None keeps the legacy “tick forever” behaviour for
callers (chiefly tests) that don’t drive a shutdown signal.