pub struct AuditLogger { /* private fields */ }Expand description
Handles writing audit entries to the audit log file
The log file uses a line-delimited JSON format (JSONL) where each line is a complete JSON object representing one audit entry.
Implementations§
Source§impl AuditLogger
impl AuditLogger
Sourcepub fn new(log_path: PathBuf) -> Self
pub fn new(log_path: PathBuf) -> Self
Create a new AuditLogger that writes to the specified path
Sourcepub fn log(&self, entry: &AuditEntry) -> EnvelopeResult<()>
pub fn log(&self, entry: &AuditEntry) -> EnvelopeResult<()>
Log an audit entry
Appends the entry as a JSON line to the audit log file. Each write is flushed immediately to ensure durability.
Sourcepub fn log_batch(&self, entries: &[AuditEntry]) -> EnvelopeResult<()>
pub fn log_batch(&self, entries: &[AuditEntry]) -> EnvelopeResult<()>
Log multiple audit entries atomically
Writes all entries and flushes once at the end.
Sourcepub fn read_all(&self) -> EnvelopeResult<Vec<AuditEntry>>
pub fn read_all(&self) -> EnvelopeResult<Vec<AuditEntry>>
Read all audit entries from the log file
Returns entries in chronological order (oldest first).
Sourcepub fn read_recent(&self, count: usize) -> EnvelopeResult<Vec<AuditEntry>>
pub fn read_recent(&self, count: usize) -> EnvelopeResult<Vec<AuditEntry>>
Read the most recent N entries from the log
Sourcepub fn entry_count(&self) -> EnvelopeResult<usize>
pub fn entry_count(&self) -> EnvelopeResult<usize>
Get the number of entries in the audit log
Auto Trait Implementations§
impl Freeze for AuditLogger
impl RefUnwindSafe for AuditLogger
impl Send for AuditLogger
impl Sync for AuditLogger
impl Unpin for AuditLogger
impl UnwindSafe for AuditLogger
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more