pub struct AsyncLogger { /* private fields */ }Expand description
Async wrapper that provides non-blocking logging.
Events are sent to a background task that handles the actual logging, allowing the caller to continue without waiting for I/O.
Implementations§
Source§impl AsyncLogger
impl AsyncLogger
Sourcepub fn new<L: AuditLogger + 'static>(inner: L, config: &AuditConfig) -> Self
pub fn new<L: AuditLogger + 'static>(inner: L, config: &AuditConfig) -> Self
Create a new async logger wrapping the given backend.
Sourcepub fn wrap<L: AuditLogger + 'static>(inner: L) -> Self
pub fn wrap<L: AuditLogger + 'static>(inner: L) -> Self
Create with default buffer size.
Sourcepub async fn shutdown(&self) -> Result<(), AuditError>
pub async fn shutdown(&self) -> Result<(), AuditError>
Gracefully shutdown the logger.
Trait Implementations§
Source§impl AuditLogger for AsyncLogger
impl AuditLogger for AsyncLogger
Source§fn log<'life0, 'async_trait>(
&'life0 self,
event: AuditEvent,
) -> Pin<Box<dyn Future<Output = Result<(), AuditError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn log<'life0, 'async_trait>(
&'life0 self,
event: AuditEvent,
) -> Pin<Box<dyn Future<Output = Result<(), AuditError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Log an audit event.
Source§fn flush<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), AuditError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn flush<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), AuditError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Flush any buffered events.
Source§fn log_batch<'life0, 'async_trait>(
&'life0 self,
events: Vec<AuditEvent>,
) -> Pin<Box<dyn Future<Output = Result<(), AuditError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn log_batch<'life0, 'async_trait>(
&'life0 self,
events: Vec<AuditEvent>,
) -> Pin<Box<dyn Future<Output = Result<(), AuditError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Log multiple events in a batch.
Source§fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), AuditError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), AuditError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Check if the logger is healthy.
Auto Trait Implementations§
impl Freeze for AsyncLogger
impl RefUnwindSafe for AsyncLogger
impl Send for AsyncLogger
impl Sync for AsyncLogger
impl Unpin for AsyncLogger
impl UnsafeUnpin for AsyncLogger
impl UnwindSafe for AsyncLogger
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