Expand description
Provides sinks to flexibly output log messages to specified targets.
§Sink
Sinks are the objects that actually write logs to their targets. Each sink
should be responsible for only single target (e.g file, console, database),
and each sink has its own private instance of Formatter
object.
A sink has its own level filter that is not shared with the logger, and a
Logger
can combine multiple Sink
s.
§Combined sink
A combined sink is also a sink, but instead of having its own target and formatter, it combines other sinks (as sub-sinks).
Operations on a combined sink will be forwarded to its sub-sinks according to the implementation.
§Asynchronous combined sink
Asynchronous combined sink is a type of combined sink. Expensive operations
(such as log
and flush
) on asynchronous sinks will be performed
asynchronously on other threads.
Since there is no waiting, errors that occur while performing asynchronous operations will not be returned to the upper level, and instead the error handler of the sink will be called.
Users should only use asynchronous combined sinks to wrap actual sinks that require a long time for operations (e.g. involving UDP sends), otherwise they will not get a performance boost or even worse.
Since the thread pool has a capacity limit, the queue may be full in some cases. When users encounter this situation, they have the following options:
-
Adjust to a larger capacity via
ThreadPoolBuilder::capacity
. -
Adjust the overflow policy via
AsyncPoolSinkBuilder::overflow_policy
. -
Set up an error handler on asynchronous combined sinks via
AsyncPoolSinkBuilder::error_handler
. The handler will be called when a record is dropped or an operation has failed.
Structs§
- AsyncPoolSink
multi-thread
A combined sink, logging and flushing asynchronously (thread-pool-based). - AsyncPoolSinkBuilder
multi-thread
The builder ofAsyncPoolSink
. - A sink with a file as the target.
- The builder of
FileSink
. - JournaldSinkLinux and
native
andlibsystemd
A sink with systemd-journal as the target. - JournaldSinkBuilderLinux and
native
andlibsystemd
The builder ofJournaldSink
. - A sink with a collection of files as the target, rotating according to the rotation policy.
- The builder of
RotatingFileSink
. - A sink with a std stream as the target.
- The builder of
StdStreamSink
. - WinDebugSinkWindows and
native
A sink with a win32 APIOutputDebugStringW
as the target. - WinDebugSinkBuilderWindows and
native
The builder ofWinDebugSink
. - A sink that writes log messages into an arbitrary
impl Write
object. - The builder of
WriteSink
.
Enums§
- OverflowPolicy
multi-thread
Overflow policy for asynchronous sinks. - Rotation policies for
RotatingFileSink
. - An enum representing the available standard streams.
Traits§
- A trait for sinks.
Type Aliases§
- A container for
Sink
s.