pub struct AuditLogger { /* private fields */ }Expand description
Async writer that appends AuditEntry records to a structured JSONL log.
Create via AuditLogger::from_config and share behind an Arc. Each executor
that should emit audit records accepts the logger via a builder method
(e.g. ShellExecutor::with_audit).
§Thread safety
File writes are serialized through an internal tokio::sync::Mutex<File>.
Multiple concurrent log calls are safe but may block briefly on the mutex.
Implementations§
Source§impl AuditLogger
impl AuditLogger
Sourcepub async fn from_config(
config: &AuditConfig,
tui_mode: bool,
) -> Result<Self, Error>
pub async fn from_config( config: &AuditConfig, tui_mode: bool, ) -> Result<Self, Error>
Create a new AuditLogger from config.
When tui_mode is true and config.destination is "stdout", the
destination is redirected to a file (audit.jsonl in the current directory)
to avoid corrupting the TUI output with raw JSON lines.
§Errors
Returns an error if a file destination cannot be opened.
Sourcepub async fn log(&self, entry: &AuditEntry)
pub async fn log(&self, entry: &AuditEntry)
Serialize entry to JSON and append it to the configured destination.
Serialization errors are logged via tracing::error! and silently swallowed so
that audit failures never interrupt tool execution.
Sourcepub async fn log_egress(&self, event: &EgressEvent)
pub async fn log_egress(&self, event: &EgressEvent)
Serialize an EgressEvent onto the same JSONL destination as AuditEntry.
Ordering with respect to AuditLogger::log is preserved by the shared
tokio::sync::Mutex<File> that serializes all writes on the same destination.
Serialization errors are logged via tracing::error! and silently swallowed
so that egress logging failures never interrupt tool execution.
Trait Implementations§
Auto 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
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