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)
8 * \file severity_channel_logger.hpp
9 * \author Andrey Semashev
12 * The header contains implementation of a logger with severity level and channel support.
15 #ifndef BOOST_LOG_SOURCES_SEVERITY_CHANNEL_LOGGER_HPP_INCLUDED_
16 #define BOOST_LOG_SOURCES_SEVERITY_CHANNEL_LOGGER_HPP_INCLUDED_
19 #include <boost/log/detail/config.hpp>
20 #if !defined(BOOST_LOG_NO_THREADS)
21 #include <boost/log/detail/light_rw_mutex.hpp>
22 #endif // !defined(BOOST_LOG_NO_THREADS)
23 #include <boost/log/sources/features.hpp>
24 #include <boost/log/sources/basic_logger.hpp>
25 #include <boost/log/sources/threading_models.hpp>
26 #include <boost/log/sources/severity_feature.hpp>
27 #include <boost/log/sources/channel_feature.hpp>
28 #include <boost/log/detail/header.hpp>
30 #ifdef BOOST_HAS_PRAGMA_ONCE
36 BOOST_LOG_OPEN_NAMESPACE
40 #ifndef BOOST_LOG_DOXYGEN_PASS
42 #ifdef BOOST_LOG_USE_CHAR
44 //! Narrow-char logger with severity level and channel support
45 template< typename LevelT = int, typename ChannelT = std::string >
46 class severity_channel_logger :
47 public basic_composite_logger<
49 severity_channel_logger< LevelT, ChannelT >,
57 BOOST_LOG_FORWARD_LOGGER_MEMBERS_TEMPLATE(severity_channel_logger)
60 #if !defined(BOOST_LOG_NO_THREADS)
62 //! Narrow-char thread-safe logger with severity level and channel support
63 template< typename LevelT = int, typename ChannelT = std::string >
64 class severity_channel_logger_mt :
65 public basic_composite_logger<
67 severity_channel_logger_mt< LevelT, ChannelT >,
68 multi_thread_model< boost::log::aux::light_rw_mutex >,
75 BOOST_LOG_FORWARD_LOGGER_MEMBERS_TEMPLATE(severity_channel_logger_mt)
78 #endif // !defined(BOOST_LOG_NO_THREADS)
80 #endif // BOOST_LOG_USE_CHAR
82 #ifdef BOOST_LOG_USE_WCHAR_T
84 //! Wide-char logger with severity level and channel support
85 template< typename LevelT = int, typename ChannelT = std::wstring >
86 class wseverity_channel_logger :
87 public basic_composite_logger<
89 wseverity_channel_logger< LevelT, ChannelT >,
97 BOOST_LOG_FORWARD_LOGGER_MEMBERS_TEMPLATE(wseverity_channel_logger)
100 #if !defined(BOOST_LOG_NO_THREADS)
102 //! Wide-char thread-safe logger with severity level and channel support
103 template< typename LevelT = int, typename ChannelT = std::wstring >
104 class wseverity_channel_logger_mt :
105 public basic_composite_logger<
107 wseverity_channel_logger_mt< LevelT, ChannelT >,
108 multi_thread_model< boost::log::aux::light_rw_mutex >,
115 BOOST_LOG_FORWARD_LOGGER_MEMBERS_TEMPLATE(wseverity_channel_logger_mt)
118 #endif // !defined(BOOST_LOG_NO_THREADS)
120 #endif // BOOST_LOG_USE_WCHAR_T
122 #else // BOOST_LOG_DOXYGEN_PASS
125 * \brief Narrow-char logger. Functionally equivalent to \c basic_severity_logger and \c basic_channel_logger.
127 * See \c severity and \c channel class templates for a more detailed description
129 template< typename LevelT = int, typename ChannelT = std::string >
130 class severity_channel_logger :
131 public basic_composite_logger<
133 severity_channel_logger< LevelT, ChannelT >,
143 * Default constructor
145 severity_channel_logger();
149 severity_channel_logger(severity_channel_logger const& that);
151 * Constructor with named arguments
153 template< typename... ArgsT >
154 explicit severity_channel_logger(ArgsT... const& args);
156 * Assignment operator
158 severity_channel_logger& operator= (severity_channel_logger const& that)
162 void swap(severity_channel_logger& that);
166 * \brief Narrow-char thread-safe logger. Functionally equivalent to \c basic_severity_logger and \c basic_channel_logger.
168 * See \c severity and \c channel class templates for a more detailed description
170 template< typename LevelT = int, typename ChannelT = std::string >
171 class severity_channel_logger_mt :
172 public basic_composite_logger<
174 severity_channel_logger_mt< LevelT, ChannelT >,
175 multi_thread_model< implementation_defined >,
184 * Default constructor
186 severity_channel_logger_mt();
190 severity_channel_logger_mt(severity_channel_logger_mt const& that);
192 * Constructor with named arguments
194 template< typename... ArgsT >
195 explicit severity_channel_logger_mt(ArgsT... const& args);
197 * Assignment operator
199 severity_channel_logger_mt& operator= (severity_channel_logger_mt const& that)
203 void swap(severity_channel_logger_mt& that);
207 * \brief Wide-char logger. Functionally equivalent to \c basic_severity_logger and \c basic_channel_logger.
209 * See \c severity and \c channel class templates for a more detailed description
211 template< typename LevelT = int, typename ChannelT = std::wstring >
212 class wseverity_channel_logger :
213 public basic_composite_logger<
215 wseverity_channel_logger< LevelT, ChannelT >,
225 * Default constructor
227 wseverity_channel_logger();
231 wseverity_channel_logger(wseverity_channel_logger const& that);
233 * Constructor with named arguments
235 template< typename... ArgsT >
236 explicit wseverity_channel_logger(ArgsT... const& args);
238 * Assignment operator
240 wseverity_channel_logger& operator= (wseverity_channel_logger const& that)
244 void swap(wseverity_channel_logger& that);
248 * \brief Wide-char thread-safe logger. Functionally equivalent to \c basic_severity_logger and \c basic_channel_logger.
250 * See \c severity and \c channel class templates for a more detailed description
252 template< typename LevelT = int, typename ChannelT = std::wstring >
253 class wseverity_channel_logger_mt :
254 public basic_composite_logger<
256 wseverity_channel_logger_mt< LevelT, ChannelT >,
257 multi_thread_model< implementation_defined >,
266 * Default constructor
268 wseverity_channel_logger_mt();
272 wseverity_channel_logger_mt(wseverity_channel_logger_mt const& that);
274 * Constructor with named arguments
276 template< typename... ArgsT >
277 explicit wseverity_channel_logger_mt(ArgsT... const& args);
279 * Assignment operator
281 wseverity_channel_logger_mt& operator= (wseverity_channel_logger_mt const& that)
285 void swap(wseverity_channel_logger_mt& that);
288 #endif // BOOST_LOG_DOXYGEN_PASS
290 } // namespace sources
292 BOOST_LOG_CLOSE_NAMESPACE // namespace log
296 //! The macro allows to put a record with a specific channel name into log
297 #define BOOST_LOG_STREAM_CHANNEL_SEV(logger, chan, lvl)\
298 BOOST_LOG_STREAM_WITH_PARAMS((logger), (::boost::log::keywords::channel = (chan))(::boost::log::keywords::severity = (lvl)))
300 #ifndef BOOST_LOG_NO_SHORTHAND_NAMES
302 //! An equivalent to BOOST_LOG_STREAM_CHANNEL_SEV(logger, chan, lvl)
303 #define BOOST_LOG_CHANNEL_SEV(logger, chan, lvl) BOOST_LOG_STREAM_CHANNEL_SEV(logger, chan, lvl)
305 #endif // BOOST_LOG_NO_SHORTHAND_NAMES
307 #include <boost/log/detail/footer.hpp>
309 #endif // BOOST_LOG_SOURCES_SEVERITY_CHANNEL_LOGGER_HPP_INCLUDED_