...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::text_ipc_message_queue_backend — An implementation of a text interprocess message queue sink backend and a supporting interprocess message queue.
// In header: <boost/log/sinks/text_ipc_message_queue_backend.hpp> template<typename QueueT> class text_ipc_message_queue_backend : public basic_formatted_sink_backend< char, concurrent_feeding > { public: // types typedef base_type::char_type char_type; // Character type. typedef base_type::string_type string_type; // String type to be used as a message text holder. typedef QueueT queue_type; // Interprocess message queue type. // construct/copy/destruct text_ipc_message_queue_backend() noexcept; explicit text_ipc_message_queue_backend(queue_type &&) noexcept; template<typename... Args> explicit text_ipc_message_queue_backend(Args &&...); // public member functions queue_type & message_queue() noexcept; queue_type const & message_queue() const noexcept; bool is_open() const noexcept; void consume(record_view const &, string_type const &); };
The sink backend sends formatted log messages to an interprocess message queue which can be extracted by a viewer process. Methods of this class are not thread-safe, unless otherwise specified.
text_ipc_message_queue_backend
public
construct/copy/destructtext_ipc_message_queue_backend() noexcept;
Default constructor. The method constructs the backend using the default-constructed interprocess message queue. The queue may need additional setup in order to be able to send messages.
explicit text_ipc_message_queue_backend(queue_type && queue) noexcept;
Initializing constructor. The method constructs the backend using the provided interprocess message queue. The constructor moves from the provided queue.
template<typename... Args> explicit text_ipc_message_queue_backend(Args &&... args);
Constructor that passes arbitrary named parameters to the interprocess queue constructor. Refer to the queue documentation for the list of supported parameters.
text_ipc_message_queue_backend
public member functionsqueue_type & message_queue() noexcept;
The method returns a reference to the managed queue_type
object.
Returns: |
A reference to the managed |
queue_type const & message_queue() const noexcept;
The method returns a constant reference to the managed queue_type
object.
Returns: |
A constant reference to the managed |
bool is_open() const noexcept;
Tests whether the object is associated with any message queue. Only when the backend has an associated message queue, will any message be sent.
Returns: |
|
void consume(record_view const &, string_type const & formatted_message);
The method writes the message to the backend. Concurrent calls to this method are allowed. Therefore, the backend may be used with unlocked frontend. stop_local()
can be used to have a blocked consume()
call return and prevent future calls to consume()
from blocking.