annotate DEPENDENCIES/generic/include/boost/log/trivial.hpp @ 133:4acb5d8d80b6 tip

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