...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::log::sinks::sink — A base class for a logging sink frontend.
// In header: <boost/log/sinks/sink.hpp> class sink { public: // types typedef unspecified exception_handler_type; // An exception handler type. // construct/copy/destruct explicit sink(bool); sink(sink const &) = delete; sink & operator=(sink const &) = delete; virtual ~sink(); // public member functions virtual bool will_consume(attribute_value_set const &) = 0; virtual void consume(record_view const &) = 0; virtual bool try_consume(record_view const &); virtual void flush() = 0; bool is_cross_thread() const noexcept; };
sink
public member functionsvirtual bool will_consume(attribute_value_set const & attributes) = 0;
The method returns true
if no filter is set or the attribute values pass the filter
Parameters: |
|
virtual void consume(record_view const & rec) = 0;
The method puts logging record to the sink
Parameters: |
|
virtual bool try_consume(record_view const & rec);
The method attempts to put logging record to the sink. The method may be used by the core in order to determine the most efficient order of sinks to feed records to in case of heavy contention. Sink implementations may implement try/backoff logic in order to improve overall logging throughput.
Parameters: |
|
||
Returns: |
|
virtual void flush() = 0;
The method performs flushing of any internal buffers that may hold log records. The method may take considerable time to complete and may block both the calling thread and threads attempting to put new records into the sink while this call is in progress.
bool is_cross_thread() const noexcept;
The method indicates that the sink passes log records between different threads. This information is needed by the logging core to detach log records from all thread-specific resources before passing it to the sink.