Spaces:
Build error
Build error
File size: 648 Bytes
1295969 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | //! ISO 9001 §7.5 append-only audit store.
use std::sync::Mutex;
use tracing::info;
#[allow(dead_code)]
pub struct AuditStore {
entries: Mutex<Vec<String>>,
path: String,
}
impl AuditStore {
pub fn open(path: &str) -> anyhow::Result<Self> {
Ok(Self {
entries: Mutex::new(Vec::new()),
path: path.to_string(),
})
}
pub fn record(&self, msg: &str) -> anyhow::Result<()> {
let entry = format!("[{}] {}", chrono::Utc::now().to_rfc3339(), msg);
info!(audit=%entry);
if let Ok(mut v) = self.entries.lock() {
v.push(entry);
}
Ok(())
}
}
|