pub struct AuditLogger { /* private fields */ }Expand description
Audit logger for tracking all mitigation activities.
Hot-path counters (total_mitigations, successful_mitigations)
are kept in AtomicU64 so they can be read from sync contexts
(e.g. ResponseSystem::metrics()) without acquiring the async
RwLock that guards the full AuditStatistics record. The atomics
and the lock are kept in sync — atomics are bumped before the
lock-protected stats are mutated, so an observer never sees a
counter that’s smaller than the lock-protected version.
Implementations§
Source§impl AuditLogger
impl AuditLogger
Sourcepub fn with_max_entries(max_entries: usize) -> Self
pub fn with_max_entries(max_entries: usize) -> Self
Create with custom max entries
Sourcepub async fn log_mitigation_start(&self, context: &ThreatContext)
pub async fn log_mitigation_start(&self, context: &ThreatContext)
Log mitigation start
Sourcepub async fn log_mitigation_success(
&self,
context: &ThreatContext,
outcome: &MitigationOutcome,
)
pub async fn log_mitigation_success( &self, context: &ThreatContext, outcome: &MitigationOutcome, )
Log successful mitigation
Sourcepub async fn log_mitigation_failure(
&self,
context: &ThreatContext,
error: &ResponseError,
)
pub async fn log_mitigation_failure( &self, context: &ThreatContext, error: &ResponseError, )
Log failed mitigation
Sourcepub async fn log_rollback(&self, action_id: &str, success: bool)
pub async fn log_rollback(&self, action_id: &str, success: bool)
Log rollback event
Sourcepub async fn log_strategy_update(&self, strategy_id: &str, details: Value)
pub async fn log_strategy_update(&self, strategy_id: &str, details: Value)
Log strategy update
Sourcepub fn total_mitigations(&self) -> u64
pub fn total_mitigations(&self) -> u64
Get total mitigations count (sync, lock-free).
Sourcepub fn successful_mitigations(&self) -> u64
pub fn successful_mitigations(&self) -> u64
Get successful mitigations count (sync, lock-free).
Sourcepub async fn entries(&self) -> Vec<AuditEntry>
pub async fn entries(&self) -> Vec<AuditEntry>
Get audit entries
Sourcepub async fn statistics(&self) -> AuditStatistics
pub async fn statistics(&self) -> AuditStatistics
Get audit statistics
Sourcepub async fn query(&self, criteria: AuditQuery) -> Vec<AuditEntry>
pub async fn query(&self, criteria: AuditQuery) -> Vec<AuditEntry>
Query entries by criteria
Sourcepub async fn export(
&self,
format: ExportFormat,
) -> Result<String, ResponseError>
pub async fn export( &self, format: ExportFormat, ) -> Result<String, ResponseError>
Export audit log