pub struct ActivityLogger { /* private fields */ }Expand description
Activity logging service with optional disk persistence.
Implementations§
Source§impl ActivityLogger
impl ActivityLogger
Sourcepub fn with_persistence(log_dir: PathBuf) -> Result<Self>
pub fn with_persistence(log_dir: PathBuf) -> Result<Self>
Create a new activity logger with persistence to the specified directory.
Sourcepub fn with_persistence_and_options(
log_dir: PathBuf,
max_log_size: u64,
max_memory_entries: usize,
) -> Result<Self>
pub fn with_persistence_and_options( log_dir: PathBuf, max_log_size: u64, max_memory_entries: usize, ) -> Result<Self>
Create a new activity logger with persistence and custom options.
Sourcepub fn verify_integrity(&self) -> Result<usize, String>
pub fn verify_integrity(&self) -> Result<usize, String>
Verify the integrity of all persisted audit logs. Returns Ok(record_count) if integrity is verified, Err with details otherwise.
Note: If old log files have been cleaned up due to rotation limits, the first remaining file’s first record will have a prev_hash that references the (now deleted) previous file. In this case, we accept the first record’s prev_hash as valid and continue verification from there.
Sourcepub fn verify_integrity_strict(&self) -> Result<usize, String>
pub fn verify_integrity_strict(&self) -> Result<usize, String>
Verify integrity with strict mode - requires chain to start from “genesis”. Use this for complete audit verification when all log files are present.
Sourcepub fn log(&self, activity_type: ActivityType, description: &str) -> String
pub fn log(&self, activity_type: ActivityType, description: &str) -> String
Log a new activity.
Sourcepub fn log_query(&self, sql: &str, duration_ms: u64, user: Option<&str>)
pub fn log_query(&self, sql: &str, duration_ms: u64, user: Option<&str>)
Log a query activity with duration.
Sourcepub fn log_config(&self, description: &str, user: Option<&str>)
pub fn log_config(&self, description: &str, user: Option<&str>)
Log a configuration change.
Sourcepub fn log_system(&self, description: &str)
pub fn log_system(&self, description: &str)
Log a system event.
Sourcepub fn log_with_details(
&self,
activity_type: ActivityType,
description: &str,
duration: Option<u64>,
user: Option<&str>,
source: Option<&str>,
details: Option<Value>,
) -> String
pub fn log_with_details( &self, activity_type: ActivityType, description: &str, duration: Option<u64>, user: Option<&str>, source: Option<&str>, details: Option<Value>, ) -> String
Log an activity with full details.
Sourcepub fn get_recent(&self, limit: usize) -> Vec<Activity>
pub fn get_recent(&self, limit: usize) -> Vec<Activity>
Get recent activities.
Sourcepub fn get_by_type(
&self,
activity_type: ActivityType,
limit: usize,
) -> Vec<Activity>
pub fn get_by_type( &self, activity_type: ActivityType, limit: usize, ) -> Vec<Activity>
Get activities by type.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ActivityLogger
impl !RefUnwindSafe for ActivityLogger
impl Send for ActivityLogger
impl Sync for ActivityLogger
impl Unpin for ActivityLogger
impl UnsafeUnpin for ActivityLogger
impl UnwindSafe for ActivityLogger
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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