Expand description
Operational logging facility (PR-5 of issue #487).
Routes the binary’s existing tracing::info! / tracing::warn! /
tracing::error! call sites through a rotating, on-disk file
appender so operators can ingest server logs into Splunk, Datadog,
Loki, etc.
Default-OFF. Without a [logging] block in config.toml the
daemon keeps the legacy tracing-subscriber::fmt setup that writes
to stderr. Enabling file logging is opt-in:
[logging]
enabled = true
path = "~/.local/state/ai-memory/logs/"
max_size_mb = 100
max_files = 30
retention_days = 90
structured = false
level = "info"See docs/security/audit-trail.md
for the SIEM ingestion guide.
Functions§
- build_
appender - Build the rolling file appender with the rotation policy from
cfg. Defaults to daily rotation withmax_filesretained on disk. - init_
file_ logging - Initialise the file logging facility. Returns a
WorkerGuardthat the caller MUST keep alive for the lifetime of the process — when dropped it flushes the in-memory buffer to disk. ReturnsNonewhen logging is disabled. - resolve_
log_ dir - Resolve the configured log directory honouring the user-mandated
precedence ladder: CLI > env (
AI_MEMORY_LOG_DIR) >[logging] pathin config > platform default. Thecfg-only entry point is kept for callers that don’t have a CLI override; subcommand wiring usesresolve_log_dir_with_overridedirectly. - resolve_
log_ dir_ with_ override - Strict version: returns the
log_paths::ResolvedDirso callers can surface the resolution layer in error messages, and propagates the world-writable-refusal error.