File indexing completed on 2025-01-30 09:45:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef BOOST_LOG_TRIVIAL_HPP_INCLUDED_
0016 #define BOOST_LOG_TRIVIAL_HPP_INCLUDED_
0017
0018 #include <cstddef>
0019 #include <iosfwd>
0020 #include <ostream>
0021 #include <boost/log/detail/config.hpp>
0022 #include <boost/log/keywords/severity.hpp>
0023 #include <boost/log/sources/severity_logger.hpp>
0024 #include <boost/log/sources/record_ostream.hpp>
0025 #include <boost/log/detail/header.hpp>
0026
0027 #ifdef BOOST_HAS_PRAGMA_ONCE
0028 #pragma once
0029 #endif
0030
0031 #if !defined(BOOST_LOG_USE_CHAR)
0032 #error Boost.Log: Trivial logging is available for narrow-character builds only. Use advanced initialization routines to setup wide-character logging.
0033 #endif
0034
0035 namespace boost {
0036
0037 BOOST_LOG_OPEN_NAMESPACE
0038
0039 namespace trivial {
0040
0041
0042 enum severity_level
0043 {
0044 trace,
0045 debug,
0046 info,
0047 warning,
0048 error,
0049 fatal
0050 };
0051
0052
0053 template< typename CharT >
0054 BOOST_LOG_API const CharT* to_string(severity_level lvl);
0055
0056
0057 inline const char* to_string(severity_level lvl)
0058 {
0059 return boost::log::trivial::to_string< char >(lvl);
0060 }
0061
0062
0063 template< typename CharT >
0064 BOOST_LOG_API bool from_string(const CharT* str, std::size_t len, severity_level& lvl);
0065
0066
0067 template< typename CharT, typename TraitsT >
0068 inline std::basic_ostream< CharT, TraitsT >& operator<< (
0069 std::basic_ostream< CharT, TraitsT >& strm, severity_level lvl)
0070 {
0071 const CharT* str = boost::log::trivial::to_string< CharT >(lvl);
0072 if (BOOST_LIKELY(!!str))
0073 strm << str;
0074 else
0075 strm << static_cast< int >(lvl);
0076 return strm;
0077 }
0078
0079
0080 template< typename CharT, typename TraitsT >
0081 BOOST_LOG_API std::basic_istream< CharT, TraitsT >& operator>> (
0082 std::basic_istream< CharT, TraitsT >& strm, severity_level& lvl);
0083
0084
0085 #if !defined(BOOST_LOG_NO_THREADS)
0086 typedef sources::severity_logger_mt< severity_level > logger_type;
0087 #else
0088 typedef sources::severity_logger< severity_level > logger_type;
0089 #endif
0090
0091
0092
0093
0094
0095
0096
0097 struct logger
0098 {
0099
0100 typedef trivial::logger_type logger_type;
0101
0102
0103
0104
0105 static BOOST_LOG_API logger_type& get();
0106
0107
0108 #if !defined(BOOST_LOG_DOXYGEN_PASS)
0109 enum registration_line_t { registration_line = __LINE__ };
0110 static const char* registration_file() { return __FILE__; }
0111 static BOOST_LOG_API logger_type construct_logger();
0112 #endif
0113 };
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124 #define BOOST_LOG_TRIVIAL(lvl)\
0125 BOOST_LOG_STREAM_WITH_PARAMS(::boost::log::trivial::logger::get(),\
0126 (::boost::log::keywords::severity = ::boost::log::trivial::lvl))
0127
0128 }
0129
0130 BOOST_LOG_CLOSE_NAMESPACE
0131
0132 }
0133
0134 #include <boost/log/detail/footer.hpp>
0135 #if defined(BOOST_LOG_EXPRESSIONS_KEYWORD_HPP_INCLUDED_)
0136 #include <boost/log/detail/trivial_keyword.hpp>
0137 #endif
0138
0139 #endif