Skip to main content

LogRouter

Struct LogRouter 

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

日志路由器:按规则将日志路由到不同管道

按规则顺序匹配,第一个匹配的规则处理日志。 若无规则匹配,则发送到默认管道(如有)。

Implementations§

Source§

impl LogRouter

Source

pub fn new() -> Self

创建空路由器

Source

pub fn route(self, rule: RoutingRule) -> Self

添加路由规则

Source

pub fn default_pipeline(self, pipeline: LogPipeline) -> Self

设置默认管道(无规则匹配时使用)

Source

pub fn route_record(&self, record: &LogRecord)

路由一条日志记录

Source

pub fn route_batch(&self, records: &[LogRecord])

批量路由日志记录

Source

pub fn routed_count(&self) -> u64

返回已路由记录数

Source

pub fn unmatched_count(&self) -> u64

返回未匹配记录数

Source

pub fn rule_count(&self) -> usize

返回规则数量

Source

pub fn has_default(&self) -> bool

是否有默认管道

Trait Implementations§

Source§

impl Debug for LogRouter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LogRouter

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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, 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.