Skip to main content

FileAuditLogStore

Struct FileAuditLogStore 

Source
pub struct FileAuditLogStore { /* private fields */ }
Expand description

基于文件的审计日志持久化存储(JSONL 格式:每行一条 JSON)

适用场景:单机部署、轻量级审计归档、开发调试。 生产环境高并发场景建议使用 AsyncAuditWriter + FileAuditLogStore 组合, 由后台线程串行写入避免锁竞争。

Implementations§

Source§

impl FileAuditLogStore

Source

pub fn new(path: impl Into<String>) -> Self

创建文件审计日志存储,目标文件不存在时在首次 append 时自动创建

Source

pub fn path(&self) -> &str

返回存储文件路径

Trait Implementations§

Source§

impl AuditLogStore for FileAuditLogStore

Source§

fn append(&self, entry: &SqlAuditContext) -> Result<(), String>

追加一条审计日志(JSONL 格式,自动脱敏后写入)

Source§

fn read_all(&self) -> Result<Vec<SqlAuditContext>, String>

读取所有已持久化的审计日志(按行解析 JSONL)

文件不存在时返回空 vec(视为尚未持久化任何日志)。

Source§

fn clear(&self) -> Result<(), String>

清空持久化文件(删除文件,下次 append 会重新创建)

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.