Trait Sink

Source
pub trait Sink: Sync + Send {
    // Required methods
    fn log(&self, record: &Record<'_>) -> Result<()>;
    fn flush(&self) -> Result<()>;
    fn level_filter(&self) -> LevelFilter;
    fn set_level_filter(&self, level_filter: LevelFilter);
    fn set_formatter(&self, formatter: Box<dyn Formatter>);
    fn set_error_handler(&self, handler: Option<ErrorHandler>);

    // Provided method
    fn should_log(&self, level: Level) -> bool { ... }
}
Expand description

Represents a sink

Required Methods§

Source

fn log(&self, record: &Record<'_>) -> Result<()>

Logs a record.

Source

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

Flushes any buffered records.

Source

fn level_filter(&self) -> LevelFilter

Gets the log level filter.

Source

fn set_level_filter(&self, level_filter: LevelFilter)

Sets the log level filter.

Source

fn set_formatter(&self, formatter: Box<dyn Formatter>)

Sets the formatter.

Source

fn set_error_handler(&self, handler: Option<ErrorHandler>)

Sets a error handler.

Most errors that occur in Sink will be returned as directly as possible (e.g. returned to Logger), but some errors that cannot be returned immediately, this function will be called. For example, asynchronous errors.

If no handler is set, default error handler will be used.

Provided Methods§

Source

fn should_log(&self, level: Level) -> bool

Determines if a log message with the specified level would be logged.

Implementors§

Source§

impl Sink for AsyncPoolSink

Available on crate feature multi-thread only.
Source§

impl Sink for DedupSink

Source§

impl Sink for FileSink

Source§

impl Sink for JournaldSink

Available on Linux and crate feature native and crate feature libsystemd only.
Source§

impl Sink for RotatingFileSink

Source§

impl Sink for StdStreamSink

Source§

impl Sink for WinDebugSink

Available on Windows and crate feature native only.
Source§

impl<W> Sink for WriteSink<W>
where W: Write + Send,