]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/log/trivial.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / log / trivial.hpp
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 * \file log/trivial.hpp
9 * \author Andrey Semashev
10 * \date 07.11.2009
11 *
12 * This header defines tools for trivial logging support
13 */
14
15 #ifndef BOOST_LOG_TRIVIAL_HPP_INCLUDED_
16 #define BOOST_LOG_TRIVIAL_HPP_INCLUDED_
17
18 #include <iosfwd>
19 #include <ostream>
20 #include <boost/log/detail/config.hpp>
21 #include <boost/log/keywords/severity.hpp>
22 #include <boost/log/sources/severity_logger.hpp>
23 #include <boost/log/sources/record_ostream.hpp>
24 #include <boost/log/detail/header.hpp>
25
26 #ifdef BOOST_HAS_PRAGMA_ONCE
27 #pragma once
28 #endif
29
30 #if !defined(BOOST_LOG_USE_CHAR)
31 #error Boost.Log: Trivial logging is available for narrow-character builds only. Use advanced initialization routines to setup wide-character logging.
32 #endif
33
34 namespace boost {
35
36 BOOST_LOG_OPEN_NAMESPACE
37
38 namespace trivial {
39
40 //! Trivial severity levels
41 enum severity_level
42 {
43 trace,
44 debug,
45 info,
46 warning,
47 error,
48 fatal
49 };
50
51 //! Returns stringized enumeration value or \c NULL, if the value is not valid
52 BOOST_LOG_API const char* to_string(severity_level lvl);
53
54 //! Outputs stringized representation of the severity level to the stream
55 template< typename CharT, typename TraitsT >
56 inline std::basic_ostream< CharT, TraitsT >& operator<< (
57 std::basic_ostream< CharT, TraitsT >& strm, severity_level lvl)
58 {
59 const char* str = boost::log::trivial::to_string(lvl);
60 if (str)
61 strm << str;
62 else
63 strm << static_cast< int >(lvl);
64 return strm;
65 }
66
67 //! Reads stringized representation of the severity level from the stream
68 template< typename CharT, typename TraitsT >
69 BOOST_LOG_API std::basic_istream< CharT, TraitsT >& operator>> (
70 std::basic_istream< CharT, TraitsT >& strm, severity_level& lvl);
71
72 //! Trivial logger type
73 #if !defined(BOOST_LOG_NO_THREADS)
74 typedef sources::severity_logger_mt< severity_level > logger_type;
75 #else
76 typedef sources::severity_logger< severity_level > logger_type;
77 #endif
78
79 /*!
80 * \brief Trivial logger tag
81 *
82 * This tag can be used to acquire the logger that is used with lrivial logging macros.
83 * This may be useful when the logger is used with other macros which require a logger.
84 */
85 struct logger
86 {
87 //! Logger type
88 typedef trivial::logger_type logger_type;
89
90 /*!
91 * Returns a reference to the trivial logger instance
92 */
93 static BOOST_LOG_API logger_type& get();
94
95 // Implementation details - never use these
96 #if !defined(BOOST_LOG_DOXYGEN_PASS)
97 enum registration_line_t { registration_line = __LINE__ };
98 static const char* registration_file() { return __FILE__; }
99 static BOOST_LOG_API logger_type construct_logger();
100 #endif
101 };
102
103 /*!
104 * The macro is used to initiate logging. The \c lvl argument of the macro specifies one of the following
105 * severity levels: \c trace, \c debug, \c info, \c warning, \c error or \c fatal (see \c severity_level enum).
106 * Following the macro, there may be a streaming expression that composes the record message string. For example:
107 *
108 * \code
109 * BOOST_LOG_TRIVIAL(info) << "Hello, world!";
110 * \endcode
111 */
112 #define BOOST_LOG_TRIVIAL(lvl)\
113 BOOST_LOG_STREAM_WITH_PARAMS(::boost::log::trivial::logger::get(),\
114 (::boost::log::keywords::severity = ::boost::log::trivial::lvl))
115
116 } // namespace trivial
117
118 BOOST_LOG_CLOSE_NAMESPACE // namespace log
119
120 } // namespace boost
121
122 #include <boost/log/detail/footer.hpp>
123 #if defined(BOOST_LOG_EXPRESSIONS_KEYWORD_HPP_INCLUDED_)
124 #include <boost/log/detail/trivial_keyword.hpp>
125 #endif
126
127 #endif // BOOST_LOG_TRIVIAL_HPP_INCLUDED_