]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/log/example/trivial/main.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)
9 * \author Andrey Semashev
12 * \brief An example of trivial logging.
15 // #define BOOST_ALL_DYN_LINK 1
16 // #define BOOST_LOG_DYN_LINK 1
18 #include <boost/log/trivial.hpp>
19 #include <boost/log/core.hpp>
20 #include <boost/log/expressions.hpp>
22 int main(int argc
, char* argv
[])
24 // Trivial logging: all log records are written into a file
25 BOOST_LOG_TRIVIAL(trace
) << "A trace severity message";
26 BOOST_LOG_TRIVIAL(debug
) << "A debug severity message";
27 BOOST_LOG_TRIVIAL(info
) << "An informational severity message";
28 BOOST_LOG_TRIVIAL(warning
) << "A warning severity message";
29 BOOST_LOG_TRIVIAL(error
) << "An error severity message";
30 BOOST_LOG_TRIVIAL(fatal
) << "A fatal severity message";
32 // Filtering can also be applied
33 using namespace boost::log
;
35 core::get()->set_filter
37 trivial::severity
>= trivial::info
40 // Now the first two lines will not pass the filter
41 BOOST_LOG_TRIVIAL(trace
) << "A trace severity message";
42 BOOST_LOG_TRIVIAL(debug
) << "A debug severity message";
43 BOOST_LOG_TRIVIAL(info
) << "An informational severity message";
44 BOOST_LOG_TRIVIAL(warning
) << "A warning severity message";
45 BOOST_LOG_TRIVIAL(error
) << "An error severity message";
46 BOOST_LOG_TRIVIAL(fatal
) << "A fatal severity message";