pub struct AuditLogger { /* private fields */ }Expand description
Audit logger with PostgreSQL backend and optional export sinks.
Implementations§
Source§impl AuditLogger
impl AuditLogger
Sourcepub fn with_exporters(
pool: Arc<Pool>,
exporters: Vec<Box<dyn AuditExporter>>,
) -> Self
pub fn with_exporters( pool: Arc<Pool>, exporters: Vec<Box<dyn AuditExporter>>, ) -> Self
Create a new audit logger with export sinks.
Entries are written to PostgreSQL first, then exported to each sink on a best-effort basis (export failures are logged but do not fail the primary write).
Sourcepub async fn log(&self, entry: AuditEntry) -> Result<i64, AuditError>
pub async fn log(&self, entry: AuditEntry) -> Result<i64, AuditError>
Log an audit entry.
Truncates query and variables to MAX_AUDIT_FIELD_BYTES before
storing to prevent audit table bloat.
§Errors
Returns error if database operation fails.
Sourcepub async fn flush_exporters(&self) -> Result<(), AuditError>
pub async fn flush_exporters(&self) -> Result<(), AuditError>
Flush all export sinks.
Call this during graceful shutdown to ensure buffered entries are delivered.
§Errors
Returns the first flush error encountered; remaining sinks are still flushed.
Sourcepub async fn get_recent_logs(
&self,
tenant_id: i64,
level: Option<AuditLevel>,
limit: i64,
) -> Result<Vec<AuditEntry>, AuditError>
pub async fn get_recent_logs( &self, tenant_id: i64, level: Option<AuditLevel>, limit: i64, ) -> Result<Vec<AuditEntry>, AuditError>
Trait Implementations§
Source§impl Clone for AuditLogger
impl Clone for AuditLogger
Source§fn clone(&self) -> AuditLogger
fn clone(&self) -> AuditLogger
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for AuditLogger
impl !RefUnwindSafe for AuditLogger
impl Send for AuditLogger
impl Sync for AuditLogger
impl Unpin for AuditLogger
impl UnsafeUnpin 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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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