2 * Copyright Lingxi Li 2015.
3 * Copyright Andrey Semashev 2016.
4 * Distributed under the Boost Software License, Version 1.0.
5 * (See accompanying file LICENSE_1_0.txt or copy at
6 * http://www.boost.org/LICENSE_1_0.txt)
12 #include <boost/log/utility/ipc/reliable_message_queue.hpp>
13 #include <boost/log/utility/ipc/object_name.hpp>
14 #include <boost/log/utility/open_mode.hpp>
16 namespace logging
= boost::log
;
17 namespace keywords
= boost::log::keywords
;
19 //[ example_sinks_ipc_receiver
24 typedef logging::ipc::reliable_message_queue queue_t
;
26 // Create a message_queue_type object that is associated with the interprocess
27 // message queue named "ipc_message_queue".
30 keywords::name
= logging::ipc::object_name(logging::ipc::object_name::user
, "ipc_message_queue"),
31 keywords::open_mode
= logging::open_mode::open_or_create
,
32 keywords::capacity
= 256,
33 keywords::block_size
= 1024,
34 keywords::overflow_policy
= queue_t::block_on_overflow
37 std::cout
<< "Viewer process running..." << std::endl
;
39 // Keep reading log messages from the associated message queue and print them on the console.
40 // queue.receive() will block if the queue is empty.
42 while (queue
.receive(message
) == queue_t::succeeded
)
44 std::cout
<< message
<< std::endl
;
46 // Clear the buffer for the next message
50 catch (std::exception
& e
)
52 std::cout
<< "Failure: " << e
.what() << std::endl
;