Skip to main content

FanOut

Struct FanOut 

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

A sink that dispatches to multiple inner sinks.

Each inner sink receives records at or below its own max_level. If an inner sink returns an error, the error is logged to stderr and dispatch continues to the remaining sinks.

use ticklog::{ConsoleSink, FanOut, Level, LogSinkExt};

let fan = FanOut::new()
    .add(ConsoleSink::stdout().with_max_level(Level::Info))
    .add(ConsoleSink::stderr().with_max_level(Level::Error));

Implementations§

Source§

impl FanOut

Source

pub fn new() -> Self

Creates an empty fan-out sink.

Source

pub fn add<S: LogSink>(self, sink: S) -> Self

Adds a sink to the fan-out set.

Trait Implementations§

Source§

impl Default for FanOut

Source§

fn default() -> Self

Creates an empty fan-out sink, the same as FanOut::new.

Source§

impl LogSink for FanOut

Source§

fn accept(&mut self, line: &[u8], level: Level) -> Result<()>

Writes a formatted log line to this sink. Read more
Source§

fn max_level(&self) -> Level

Maximum Level this sink accepts. Read more
Source§

fn flush(&mut self) -> Result<()>

Flushes any buffered output to the underlying destination. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for FanOut

§

impl !Sync for FanOut

§

impl !UnwindSafe for FanOut

§

impl Freeze for FanOut

§

impl Send for FanOut

§

impl Unpin for FanOut

§

impl UnsafeUnpin for FanOut

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> LogSinkExt for T
where T: LogSink,

Source§

fn with_max_level(self, level: Level) -> WithLevel<Self>

Wraps this sink in a WithLevel adapter that limits accepted records to level and below.
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.