Expand description
Comprehensive audit logging for security compliance and incident investigation.
This module provides structured audit logging capabilities that track all critical operations in the memory system. Audit logs are designed for:
- Security compliance: Meet regulatory requirements for data access tracking
- Incident investigation: Reconstruct events leading to issues
- Forensic analysis: Understand system behavior and data flow
- Access control monitoring: Detect unauthorized access attempts
§Features
- Structured JSON logging for machine parsing
- Millisecond-precision timestamps
- User/agent identification
- Before/after state tracking for modifications
- Configurable log levels and destinations
- Minimal performance overhead (<5% when enabled)
§Configuration
Audit logging is disabled by default for development environments. Enable via configuration:
use do_memory_core::security::audit::{AuditConfig, AuditLogger, AuditLogLevel, AuditOutput};
let config = AuditConfig {
enabled: true,
log_level: AuditLogLevel::Info,
output_destination: AuditOutput::Stdout,
retention_days: 90,
include_state_changes: true,
include_ip_address: false,
include_session_info: false,
buffer_size: 100,
};
let logger = AuditLogger::new(config);§Environment Variables
MEMORY_AUDIT_ENABLED: Enable/disable audit logging (true/false)MEMORY_AUDIT_LEVEL: Log level (debug,info,warn,error)MEMORY_AUDIT_OUTPUT: Output destination (stdout,stderr,file)MEMORY_AUDIT_FILE: File path when output isfileMEMORY_AUDIT_RETENTION_DAYS: Log retention period in days
Structs§
- Audit
Config - Configuration for audit logging.
- Audit
Context - Context for audit logging operations.
- Audit
Entry - A single audit log entry.
- Audit
Logger - Async audit logger with buffering and configurable output.
Enums§
- Actor
Type - Actor type performing the action.
- Audit
Event Type - Types of audit events.
- Audit
LogLevel - Severity level for audit log entries.
- Audit
Output - Output destination for audit logs.
- Audit
Result - Result of an audited operation.
Functions§
- access_
denied - Create an audit entry for access denial.
- config_
changed - Create an audit entry for configuration changes.
- episode_
completed - Create an audit entry for episode completion.
- episode_
created - Create an audit entry for episode creation.
- episode_
deleted - Create an audit entry for episode deletion.
- relationship_
added - Create an audit entry for relationship addition.
- relationship_
removed - Create an audit entry for relationship removal.
- tags_
modified - Create an audit entry for tag modification.