]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/log/example/doc/util_manip_to_log.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)
11 #include <boost/log/utility/formatting_ostream.hpp>
12 #include <boost/log/utility/manipulators/to_log.hpp>
14 namespace logging
= boost::log
;
16 //[ example_utility_manipulators_to_log
17 std::ostream
& operator<<
20 logging::to_log_manip
< int > const& manip
23 strm
<< std::setw(4) << std::setfill('0') << std::hex
<< manip
.get() << std::dec
;
29 std::cout
<< "Regular output: " << 1010 << std::endl
;
30 std::cout
<< "Log output: " << logging::to_log(1010) << std::endl
;
34 //[ example_utility_manipulators_to_log_with_tag
38 std::ostream
& operator<<
41 logging::to_log_manip
< int, tag_A
> const& manip
44 strm
<< "A[" << manip
.get() << "]";
48 std::ostream
& operator<<
51 logging::to_log_manip
< int, tag_B
> const& manip
54 strm
<< "B[" << manip
.get() << "]";
58 void test_manip_with_tag()
60 std::cout
<< "Regular output: " << 1010 << std::endl
;
61 std::cout
<< "Log output A: " << logging::to_log
< tag_A
>(1010) << std::endl
;
62 std::cout
<< "Log output B: " << logging::to_log
< tag_B
>(1010) << std::endl
;
67 int main(int, char*[])
70 test_manip_with_tag();