Trait spdlog::sink::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

A trait for sinks.

Required Methods§

source

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

Logs a record.

Implementors should always call Sink::should_log internally to filter records.

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.

Any errors that occur in Sink will be returned as directly as possible (e.g. returned to Logger), but some errors that are not likely to be returned directly will call this error handler. Most of these errors are uncommon.

If no handler is set, errors will be print to stderr and then ignored.

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