pub trait Sink:
SinkPropAccess
+ Sync
+ Send {
// Required methods
fn log(&self, record: &Record<'_>) -> Result<()>;
fn flush(&self) -> Result<()>;
// Provided methods
fn should_log(&self, level: Level) -> bool { ... }
fn flush_on_exit(&self) -> Result<()> { ... }
}Expand description
Represents a sink
See ./examples directory for how to implement a custom sink.
Required Methods§
Provided Methods§
Sourcefn should_log(&self, level: Level) -> bool
fn should_log(&self, level: Level) -> bool
Determines if a log message with the specified level would be logged.
Sourcefn flush_on_exit(&self) -> Result<()>
fn flush_on_exit(&self) -> Result<()>
Flushes any buffered records at program exit.
spdlog-rs will perform a flush for sinks in the default logger when
the program exits, and the flush will be called to this method
flush_on_exit instead of flush. This is because the execution
context may be in the atexit callback or in the panic handler when
exiting. In such a context, some operations are restricted, e.g.
Thread-local Storage (TLS) may not be available in atexit callbacks.
This method calls directly to flush method by default. When users’
flush method implementation is not usable in a program exit context,
users should override the implementation of this method to provide an
alternative flushing implementation. See the implementation of
AsyncPoolSink::flush_on_exit as an example.
For combined sinks, this method should always be overridden to
propagate the information that “the program is exiting” to their
sub-sinks. See the implementation of DedupSink::flush_on_exit as an
example.
Implementors§
impl Sink for AndroidSink
native and crate feature android-ndk only.impl Sink for AsyncPoolSink
multi-thread only.impl Sink for DedupSink
impl Sink for FileSink
impl Sink for JournaldSink
native and crate feature libsystemd only.impl Sink for RotatingFileSink
impl Sink for StdStreamSink
impl Sink for WinDebugSink
native only.