]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/log/example/doc/sinks_debugger.cpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / log / example / doc / sinks_debugger.cpp
CommitLineData
7c673cae
FG
1/*
2 * Copyright Andrey Semashev 2007 - 2015.
3 * Distributed under the Boost Software License, Version 1.0.
4 * (See accompanying file LICENSE_1_0.txt or copy at
5 * http://www.boost.org/LICENSE_1_0.txt)
6 */
7
8#include <boost/smart_ptr/shared_ptr.hpp>
9#include <boost/log/core.hpp>
10#include <boost/log/expressions/predicates/is_debugger_present.hpp>
11#include <boost/log/sinks/sync_frontend.hpp>
12#include <boost/log/sinks/debug_output_backend.hpp>
13#include <boost/log/sources/logger.hpp>
14#include <boost/log/sources/record_ostream.hpp>
15
16#if defined(BOOST_WINDOWS)
17
18namespace logging = boost::log;
19namespace expr = boost::log::expressions;
20namespace src = boost::log::sources;
21namespace sinks = boost::log::sinks;
22
23//[ example_sinks_debugger
24// Complete sink type
25typedef sinks::synchronous_sink< sinks::debug_output_backend > sink_t;
26
27void init_logging()
28{
29 boost::shared_ptr< logging::core > core = logging::core::get();
30
31 // Create the sink. The backend requires synchronization in the frontend.
32 boost::shared_ptr< sink_t > sink(new sink_t());
33
34 // Set the special filter to the frontend
35 // in order to skip the sink when no debugger is available
36 sink->set_filter(expr::is_debugger_present());
37
38 core->add_sink(sink);
39}
40//]
41
42int main(int, char*[])
43{
44 init_logging();
45
46 src::logger lg;
47 BOOST_LOG(lg) << "Hello world!";
48
49 return 0;
50}
51
52#else
53
54int main(int, char*[])
55{
56 return 0;
57}
58
59#endif