pub struct AuditLog { /* private fields */ }Expand description
The audit log — an append-only, tamper-evident log
Implementations§
Source§impl AuditLog
impl AuditLog
Sourcepub fn with_key(session_id: String, key: Vec<u8>) -> Self
pub fn with_key(session_id: String, key: Vec<u8>) -> Self
Create a new audit log with a specific key (for testing or recovery)
Sourcepub fn set_trace_logging(&mut self, enabled: bool)
pub fn set_trace_logging(&mut self, enabled: bool)
Enable or disable tracing logging
Sourcepub fn set_file_path(&mut self, path: PathBuf)
pub fn set_file_path(&mut self, path: PathBuf)
Set the file path for persistence
Sourcepub fn append(
&self,
event_type: AuditEventType,
component: &str,
description: &str,
metadata: Option<Value>,
) -> Result<AuditEntry, AuditError>
pub fn append( &self, event_type: AuditEventType, component: &str, description: &str, metadata: Option<Value>, ) -> Result<AuditEntry, AuditError>
Append an entry to the audit log
Sourcepub fn tool_call(
&self,
tool_name: &str,
args: &Value,
) -> Result<AuditEntry, AuditError>
pub fn tool_call( &self, tool_name: &str, args: &Value, ) -> Result<AuditEntry, AuditError>
Convenience method for logging a tool call
Sourcepub fn tool_result(
&self,
tool_name: &str,
result: &ToolResult,
) -> Result<AuditEntry, AuditError>
pub fn tool_result( &self, tool_name: &str, result: &ToolResult, ) -> Result<AuditEntry, AuditError>
Convenience method for logging a tool result
Sourcepub fn policy_decision(
&self,
tool_name: &str,
allowed: bool,
reason: Option<&str>,
) -> Result<AuditEntry, AuditError>
pub fn policy_decision( &self, tool_name: &str, allowed: bool, reason: Option<&str>, ) -> Result<AuditEntry, AuditError>
Convenience method for logging a policy decision
Sourcepub fn approval(
&self,
tool_name: &str,
granted: bool,
reason: Option<&str>,
) -> Result<AuditEntry, AuditError>
pub fn approval( &self, tool_name: &str, granted: bool, reason: Option<&str>, ) -> Result<AuditEntry, AuditError>
Convenience method for logging an approval
Sourcepub fn entries(&self) -> Result<Vec<AuditEntry>, AuditError>
pub fn entries(&self) -> Result<Vec<AuditEntry>, AuditError>
Get all entries
Sourcepub fn len(&self) -> Result<usize, AuditError>
pub fn len(&self) -> Result<usize, AuditError>
Get the number of entries
Sourcepub fn is_empty(&self) -> Result<bool, AuditError>
pub fn is_empty(&self) -> Result<bool, AuditError>
Check if the log is empty
Sourcepub fn verify(&self) -> Result<(), AuditError>
pub fn verify(&self) -> Result<(), AuditError>
Verify the integrity of the entire audit log
Sourcepub fn to_json(&self) -> Result<String, AuditError>
pub fn to_json(&self) -> Result<String, AuditError>
Export the audit log as JSON
Sourcepub fn to_json_lines(&self) -> Result<String, AuditError>
pub fn to_json_lines(&self) -> Result<String, AuditError>
Export the audit log as JSON lines (one entry per line)
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for AuditLog
impl RefUnwindSafe for AuditLog
impl Send for AuditLog
impl Sync for AuditLog
impl Unpin for AuditLog
impl UnsafeUnpin for AuditLog
impl UnwindSafe for AuditLog
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request