]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/log/example/doc/tutorial_logging.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/move/utility_core.hpp>
9 #include <boost/log/sources/logger.hpp>
10 #include <boost/log/sources/record_ostream.hpp>
11 #include <boost/log/sources/global_logger_storage.hpp>
12 #include <boost/log/utility/setup/file.hpp>
13 #include <boost/log/utility/setup/common_attributes.hpp>
15 namespace logging
= boost::log
;
16 namespace src
= boost::log::sources
;
17 namespace keywords
= boost::log::keywords
;
19 BOOST_LOG_INLINE_GLOBAL_LOGGER_DEFAULT(my_logger
, src::logger_mt
)
21 void logging_function1()
25 //[ example_tutorial_logging_manual_logging
26 logging::record rec
= lg
.open_record();
29 logging::record_ostream
strm(rec
);
30 strm
<< "Hello, World!";
32 lg
.push_record(boost::move(rec
));
37 void logging_function2()
39 src::logger_mt
& lg
= my_logger::get();
40 BOOST_LOG(lg
) << "Greetings from the global logger!";
43 int main(int, char*[])
45 logging::add_file_log("sample.log");
46 logging::add_common_attributes();