Skip to main content

MultiOutputLogger

Struct MultiOutputLogger 

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

多输出日志器:将日志扇出到多个 LogSink

每条日志会依次写入所有已注册的 sink。单个 sink 写入失败(panic) 不会影响其他 sink,因为 LogSink::write 要求实现方自行降级处理。

Implementations§

Source§

impl MultiOutputLogger

Source

pub fn new(level: LogLevel) -> Self

创建多输出日志器

Source

pub fn add_sink(&mut self, sink: Arc<dyn LogSink>) -> &mut Self

添加一个输出 sink

Source

pub fn sink_names(&self) -> Vec<String>

获取已注册的 sink 名称列表

Source

pub fn sink_count(&self) -> usize

获取已注册的 sink 数量

Source

pub fn level(&self) -> LogLevel

获取当前日志级别

Trait Implementations§

Source§

impl Logger for MultiOutputLogger

Source§

fn log(&self, level: LogLevel, msg: &str)

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.