Module spdlog::sink

source ·
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 Sinks.

§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:

Structs§

Enums§

Traits§

  • A trait for sinks.

Type Aliases§