pub struct AuditLogger { /* private fields */ }Expand description
Async writer that appends AuditEntry records to a structured JSONL log.
Create via AuditLogger::from_config and share behind an Arc. Each executor
that should emit audit records accepts the logger via a builder method
(e.g. ShellExecutor::with_audit).
§Thread safety
File writes are serialized through an internal tokio::sync::Mutex<File>.
Multiple concurrent log calls are safe but may block briefly on the mutex.
Implementations§
Source§impl AuditLogger
impl AuditLogger
Sourcepub async fn from_config(
config: &AuditConfig,
tui_mode: bool,
) -> Result<Self, Error>
pub async fn from_config( config: &AuditConfig, tui_mode: bool, ) -> Result<Self, Error>
Create a new AuditLogger from config.
When tui_mode is true and config.destination is "stdout", the
destination is redirected to a file (audit.jsonl in the current directory)
to avoid corrupting the TUI output with raw JSON lines.
§Errors
Returns an error if a file destination cannot be opened.
Sourcepub async fn log(&self, entry: &AuditEntry)
pub async fn log(&self, entry: &AuditEntry)
Serialize entry to JSON and append it to the configured destination.
Serialization errors are logged via tracing::error! and silently swallowed so
that audit failures never interrupt tool execution.