]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/log/example/doc/sinks_debugger.cpp
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)
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>
16 #if defined(BOOST_WINDOWS)
18 namespace logging
= boost::log
;
19 namespace expr
= boost::log::expressions
;
20 namespace src
= boost::log::sources
;
21 namespace sinks
= boost::log::sinks
;
23 //[ example_sinks_debugger
25 typedef sinks::synchronous_sink
< sinks::debug_output_backend
> sink_t
;
29 boost::shared_ptr
< logging::core
> core
= logging::core::get();
31 // Create the sink. The backend requires synchronization in the frontend.
32 boost::shared_ptr
< sink_t
> sink(new sink_t());
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());
42 int main(int, char*[])
47 BOOST_LOG(lg
) << "Hello world!";
54 int main(int, char*[])