## Class sink

boost::log::sinks::sink — A base class for a logging sink frontend.

## Synopsis

    // 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;
      ~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;
    };

## Description

### `sink` public construct/copy/destruct

1.     explicit sink(bool cross_thread);

   Default constructor

2.     sink(sink const &) = delete;

3.     sink & operator=(sink const &) = delete;

4.     ~sink();

   Virtual destructor

### `sink` public member functions

1.     virtual 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:

   `attributes` | A set of attribute values of a logging record

2.     virtual void consume(record_view const & rec) = 0;

   The method puts logging record to the sink

   Parameters:

   `rec` | Logging record to consume

3.     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:

   `rec` | Logging record to consume

   Returns: | `true`, if the record was consumed, `false`, if not.

4.     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.

5.     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.