Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:39:26

0001 /*
0002  *          Copyright Andrey Semashev 2007 - 2015.
0003  * Distributed under the Boost Software License, Version 1.0.
0004  *    (See accompanying file LICENSE_1_0.txt or copy at
0005  *          http://www.boost.org/LICENSE_1_0.txt)
0006  */
0007 /*!
0008  * \file   severity_channel_logger.hpp
0009  * \author Andrey Semashev
0010  * \date   28.02.2008
0011  *
0012  * The header contains implementation of a logger with severity level and channel support.
0013  */
0014 
0015 #ifndef BOOST_LOG_SOURCES_SEVERITY_CHANNEL_LOGGER_HPP_INCLUDED_
0016 #define BOOST_LOG_SOURCES_SEVERITY_CHANNEL_LOGGER_HPP_INCLUDED_
0017 
0018 #include <string>
0019 #include <boost/log/detail/config.hpp>
0020 #if !defined(BOOST_LOG_NO_THREADS)
0021 #include <boost/log/detail/light_rw_mutex.hpp>
0022 #endif // !defined(BOOST_LOG_NO_THREADS)
0023 #include <boost/log/sources/features.hpp>
0024 #include <boost/log/sources/basic_logger.hpp>
0025 #include <boost/log/sources/threading_models.hpp>
0026 #include <boost/log/sources/severity_feature.hpp>
0027 #include <boost/log/sources/channel_feature.hpp>
0028 #include <boost/log/detail/header.hpp>
0029 
0030 #ifdef BOOST_HAS_PRAGMA_ONCE
0031 #pragma once
0032 #endif
0033 
0034 namespace boost {
0035 
0036 BOOST_LOG_OPEN_NAMESPACE
0037 
0038 namespace sources {
0039 
0040 #ifndef BOOST_LOG_DOXYGEN_PASS
0041 
0042 #ifdef BOOST_LOG_USE_CHAR
0043 
0044 //! Narrow-char logger with severity level and channel support
0045 template< typename LevelT = int, typename ChannelT = std::string >
0046 class severity_channel_logger :
0047     public basic_composite_logger<
0048         char,
0049         severity_channel_logger< LevelT, ChannelT >,
0050         single_thread_model,
0051         features<
0052             severity< LevelT >,
0053             channel< ChannelT >
0054         >
0055     >
0056 {
0057     BOOST_LOG_FORWARD_LOGGER_MEMBERS_TEMPLATE(severity_channel_logger)
0058 };
0059 
0060 #if !defined(BOOST_LOG_NO_THREADS)
0061 
0062 //! Narrow-char thread-safe logger with severity level and channel support
0063 template< typename LevelT = int, typename ChannelT = std::string >
0064 class severity_channel_logger_mt :
0065     public basic_composite_logger<
0066         char,
0067         severity_channel_logger_mt< LevelT, ChannelT >,
0068         multi_thread_model< boost::log::aux::light_rw_mutex >,
0069         features<
0070             severity< LevelT >,
0071             channel< ChannelT >
0072         >
0073     >
0074 {
0075     BOOST_LOG_FORWARD_LOGGER_MEMBERS_TEMPLATE(severity_channel_logger_mt)
0076 };
0077 
0078 #endif // !defined(BOOST_LOG_NO_THREADS)
0079 
0080 #endif // BOOST_LOG_USE_CHAR
0081 
0082 #ifdef BOOST_LOG_USE_WCHAR_T
0083 
0084 //! Wide-char logger with severity level and channel support
0085 template< typename LevelT = int, typename ChannelT = std::wstring >
0086 class wseverity_channel_logger :
0087     public basic_composite_logger<
0088         wchar_t,
0089         wseverity_channel_logger< LevelT, ChannelT >,
0090         single_thread_model,
0091         features<
0092             severity< LevelT >,
0093             channel< ChannelT >
0094         >
0095     >
0096 {
0097     BOOST_LOG_FORWARD_LOGGER_MEMBERS_TEMPLATE(wseverity_channel_logger)
0098 };
0099 
0100 #if !defined(BOOST_LOG_NO_THREADS)
0101 
0102 //! Wide-char thread-safe logger with severity level and channel support
0103 template< typename LevelT = int, typename ChannelT = std::wstring >
0104 class wseverity_channel_logger_mt :
0105     public basic_composite_logger<
0106         wchar_t,
0107         wseverity_channel_logger_mt< LevelT, ChannelT >,
0108         multi_thread_model< boost::log::aux::light_rw_mutex >,
0109         features<
0110             severity< LevelT >,
0111             channel< ChannelT >
0112         >
0113     >
0114 {
0115     BOOST_LOG_FORWARD_LOGGER_MEMBERS_TEMPLATE(wseverity_channel_logger_mt)
0116 };
0117 
0118 #endif // !defined(BOOST_LOG_NO_THREADS)
0119 
0120 #endif // BOOST_LOG_USE_WCHAR_T
0121 
0122 #else // BOOST_LOG_DOXYGEN_PASS
0123 
0124 /*!
0125  * \brief Narrow-char logger. Functionally equivalent to \c basic_severity_logger and \c basic_channel_logger.
0126  *
0127  * See \c severity and \c channel class templates for a more detailed description
0128  */
0129 template< typename LevelT = int, typename ChannelT = std::string >
0130 class severity_channel_logger :
0131     public basic_composite_logger<
0132         char,
0133         severity_channel_logger< LevelT, ChannelT >,
0134         single_thread_model,
0135         features<
0136             severity< LevelT >,
0137             channel< ChannelT >
0138         >
0139     >
0140 {
0141 public:
0142     /*!
0143      * Default constructor
0144      */
0145     severity_channel_logger();
0146     /*!
0147      * Copy constructor
0148      */
0149     severity_channel_logger(severity_channel_logger const& that);
0150     /*!
0151      * Constructor with named arguments
0152      */
0153     template< typename... ArgsT >
0154     explicit severity_channel_logger(ArgsT... const& args);
0155     /*!
0156      * Assignment operator
0157      */
0158     severity_channel_logger& operator= (severity_channel_logger const& that)
0159     /*!
0160      * Swaps two loggers
0161      */
0162     void swap(severity_channel_logger& that);
0163 };
0164 
0165 /*!
0166  * \brief Narrow-char thread-safe logger. Functionally equivalent to \c basic_severity_logger and \c basic_channel_logger.
0167  *
0168  * See \c severity and \c channel class templates for a more detailed description
0169  */
0170 template< typename LevelT = int, typename ChannelT = std::string >
0171 class severity_channel_logger_mt :
0172     public basic_composite_logger<
0173         char,
0174         severity_channel_logger_mt< LevelT, ChannelT >,
0175         multi_thread_model< implementation_defined >,
0176         features<
0177             severity< LevelT >,
0178             channel< ChannelT >
0179         >
0180     >
0181 {
0182 public:
0183     /*!
0184      * Default constructor
0185      */
0186     severity_channel_logger_mt();
0187     /*!
0188      * Copy constructor
0189      */
0190     severity_channel_logger_mt(severity_channel_logger_mt const& that);
0191     /*!
0192      * Constructor with named arguments
0193      */
0194     template< typename... ArgsT >
0195     explicit severity_channel_logger_mt(ArgsT... const& args);
0196     /*!
0197      * Assignment operator
0198      */
0199     severity_channel_logger_mt& operator= (severity_channel_logger_mt const& that)
0200     /*!
0201      * Swaps two loggers
0202      */
0203     void swap(severity_channel_logger_mt& that);
0204 };
0205 
0206 /*!
0207  * \brief Wide-char logger. Functionally equivalent to \c basic_severity_logger and \c basic_channel_logger.
0208  *
0209  * See \c severity and \c channel class templates for a more detailed description
0210  */
0211 template< typename LevelT = int, typename ChannelT = std::wstring >
0212 class wseverity_channel_logger :
0213     public basic_composite_logger<
0214         wchar_t,
0215         wseverity_channel_logger< LevelT, ChannelT >,
0216         single_thread_model,
0217         features<
0218             severity< LevelT >,
0219             channel< ChannelT >
0220         >
0221     >
0222 {
0223 public:
0224     /*!
0225      * Default constructor
0226      */
0227     wseverity_channel_logger();
0228     /*!
0229      * Copy constructor
0230      */
0231     wseverity_channel_logger(wseverity_channel_logger const& that);
0232     /*!
0233      * Constructor with named arguments
0234      */
0235     template< typename... ArgsT >
0236     explicit wseverity_channel_logger(ArgsT... const& args);
0237     /*!
0238      * Assignment operator
0239      */
0240     wseverity_channel_logger& operator= (wseverity_channel_logger const& that)
0241     /*!
0242      * Swaps two loggers
0243      */
0244     void swap(wseverity_channel_logger& that);
0245 };
0246 
0247 /*!
0248  * \brief Wide-char thread-safe logger. Functionally equivalent to \c basic_severity_logger and \c basic_channel_logger.
0249  *
0250  * See \c severity and \c channel class templates for a more detailed description
0251  */
0252 template< typename LevelT = int, typename ChannelT = std::wstring >
0253 class wseverity_channel_logger_mt :
0254     public basic_composite_logger<
0255         wchar_t,
0256         wseverity_channel_logger_mt< LevelT, ChannelT >,
0257         multi_thread_model< implementation_defined >,
0258         features<
0259             severity< LevelT >,
0260             channel< ChannelT >
0261         >
0262     >
0263 {
0264 public:
0265     /*!
0266      * Default constructor
0267      */
0268     wseverity_channel_logger_mt();
0269     /*!
0270      * Copy constructor
0271      */
0272     wseverity_channel_logger_mt(wseverity_channel_logger_mt const& that);
0273     /*!
0274      * Constructor with named arguments
0275      */
0276     template< typename... ArgsT >
0277     explicit wseverity_channel_logger_mt(ArgsT... const& args);
0278     /*!
0279      * Assignment operator
0280      */
0281     wseverity_channel_logger_mt& operator= (wseverity_channel_logger_mt const& that)
0282     /*!
0283      * Swaps two loggers
0284      */
0285     void swap(wseverity_channel_logger_mt& that);
0286 };
0287 
0288 #endif // BOOST_LOG_DOXYGEN_PASS
0289 
0290 } // namespace sources
0291 
0292 BOOST_LOG_CLOSE_NAMESPACE // namespace log
0293 
0294 } // namespace boost
0295 
0296 //! The macro allows to put a record with a specific channel name into log
0297 #define BOOST_LOG_STREAM_CHANNEL_SEV(logger, chan, lvl)\
0298     BOOST_LOG_STREAM_WITH_PARAMS((logger), (::boost::log::keywords::channel = (chan))(::boost::log::keywords::severity = (lvl)))
0299 
0300 #ifndef BOOST_LOG_NO_SHORTHAND_NAMES
0301 
0302 //! An equivalent to BOOST_LOG_STREAM_CHANNEL_SEV(logger, chan, lvl)
0303 #define BOOST_LOG_CHANNEL_SEV(logger, chan, lvl) BOOST_LOG_STREAM_CHANNEL_SEV(logger, chan, lvl)
0304 
0305 #endif // BOOST_LOG_NO_SHORTHAND_NAMES
0306 
0307 #include <boost/log/detail/footer.hpp>
0308 
0309 #endif // BOOST_LOG_SOURCES_SEVERITY_CHANNEL_LOGGER_HPP_INCLUDED_