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.
Constants§
- DEFAULT_
LOG_ DIRECTIVE - Default
tracingEnvFilter directive applied whenRUST_LOGis unset — INFO-level for the substrate’s own crate only. One spelling for every fallback-filter construction site (pm-v3.1 gate, #1558 wave 4). - URL_
PASSWORD_ MASK - Mask substituted for the userinfo password portion of a URL by
redact_url_password/redact_urls_in_message. The username and host stay readable so operators can still correlate the log line with the deployment; only the secret is destroyed.
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. - redact_
url_ password - #1579 A3 (SECURITY) — redact the userinfo password portion of a
single URL:
postgres://user:hunter2@host:5432/dbbecomespostgres://user:****@host:5432/db. - redact_
urls_ in_ message - #1579 A3 (SECURITY) — companion to
redact_url_passwordfor free-text diagnostics that may EMBED a URL (e.g. a wrappedsqlx::Error::Configuration("invalid url postgres://…")whose Display interpolates the connection target). Scans the message forscheme://runs and masks the userinfo password inside each one; every other byte passes through unchanged. - 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.