Skip to main content

RotatingAuditor

Struct RotatingAuditor 

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

带轮转策略和审计规则的增强审计器。

SqlAuditor 基础上增加:

  • 日志轮转(按大小/时间自动清理旧日志)
  • 审计规则(允许/拒绝列表过滤)

Implementations§

Source§

impl RotatingAuditor

Source

pub fn new(policy: RotationPolicy, rules: AuditRules) -> Self

Source

pub fn with_max_entries(max_entries: usize) -> Self

创建仅按大小轮转的审计器,无规则过滤

Source

pub fn with_max_age(max_age_ms: i64) -> Self

创建仅按时间轮转的审计器,无规则过滤

Source

pub fn log(&self, ctx: &SqlAuditContext) -> bool

记录审计日志,自动应用规则过滤和轮转策略

Source

pub fn get_logs(&self) -> Vec<SqlAuditContext>

返回当前日志快照

Source

pub fn rotation_count(&self) -> usize

返回已轮转次数

Source

pub fn rotate(&self) -> usize

手动触发轮转(清空当前日志)

Source

pub fn len(&self) -> usize

返回当前日志条数

Source

pub fn is_empty(&self) -> bool

是否为空

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.