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_logger.hpp
9 * \author Andrey Semashev
12 * The header contains implementation of a logger with severity level support.
15 #ifndef BOOST_LOG_SOURCES_SEVERITY_LOGGER_HPP_INCLUDED_
16 #define BOOST_LOG_SOURCES_SEVERITY_LOGGER_HPP_INCLUDED_
18 #include <boost/log/detail/config.hpp>
19 #if !defined(BOOST_LOG_NO_THREADS)
20 #include <boost/log/detail/light_rw_mutex.hpp>
21 #endif // !defined(BOOST_LOG_NO_THREADS)
22 #include <boost/log/sources/features.hpp>
23 #include <boost/log/sources/basic_logger.hpp>
24 #include <boost/log/sources/threading_models.hpp>
25 #include <boost/log/sources/severity_feature.hpp>
26 #include <boost/log/keywords/severity.hpp>
27 #include <boost/log/detail/header.hpp>
29 #ifdef BOOST_HAS_PRAGMA_ONCE
35 BOOST_LOG_OPEN_NAMESPACE
39 #ifndef BOOST_LOG_DOXYGEN_PASS
41 #ifdef BOOST_LOG_USE_CHAR
43 //! Narrow-char logger with severity level support
44 template< typename LevelT = int >
45 class severity_logger :
46 public basic_composite_logger<
48 severity_logger< LevelT >,
50 features< severity< LevelT > >
53 typedef typename severity_logger::logger_base base_type;
56 BOOST_LOG_FORWARD_LOGGER_MEMBERS_TEMPLATE(severity_logger)
58 explicit severity_logger(LevelT level) : base_type(keywords::severity = level)
63 #if !defined(BOOST_LOG_NO_THREADS)
65 //! Narrow-char thread-safe logger with severity level support
66 template< typename LevelT = int >
67 class severity_logger_mt :
68 public basic_composite_logger<
70 severity_logger_mt< LevelT >,
71 multi_thread_model< boost::log::aux::light_rw_mutex >,
72 features< severity< LevelT > >
75 typedef typename severity_logger_mt::logger_base base_type;
78 BOOST_LOG_FORWARD_LOGGER_MEMBERS_TEMPLATE(severity_logger_mt)
80 explicit severity_logger_mt(LevelT level) : base_type(keywords::severity = level)
85 #endif // !defined(BOOST_LOG_NO_THREADS)
89 #ifdef BOOST_LOG_USE_WCHAR_T
91 //! Wide-char logger with severity level support
92 template< typename LevelT = int >
93 class wseverity_logger :
94 public basic_composite_logger<
96 wseverity_logger< LevelT >,
98 features< severity< LevelT > >
101 typedef typename wseverity_logger::logger_base base_type;
104 BOOST_LOG_FORWARD_LOGGER_MEMBERS_TEMPLATE(wseverity_logger)
106 explicit wseverity_logger(LevelT level) : base_type(keywords::severity = level)
111 #if !defined(BOOST_LOG_NO_THREADS)
113 //! Wide-char thread-safe logger with severity level support
114 template< typename LevelT = int >
115 class wseverity_logger_mt :
116 public basic_composite_logger<
118 wseverity_logger_mt< LevelT >,
119 multi_thread_model< boost::log::aux::light_rw_mutex >,
120 features< severity< LevelT > >
123 typedef typename wseverity_logger_mt::logger_base base_type;
126 BOOST_LOG_FORWARD_LOGGER_MEMBERS_TEMPLATE(wseverity_logger_mt)
128 explicit wseverity_logger_mt(LevelT level) : base_type(keywords::severity = level)
133 #endif // !defined(BOOST_LOG_NO_THREADS)
137 #else // BOOST_LOG_DOXYGEN_PASS
140 * \brief Narrow-char logger. Functionally equivalent to \c basic_severity_logger.
142 * See \c severity class template for a more detailed description
144 template< typename LevelT = int >
145 class severity_logger :
146 public basic_composite_logger<
148 severity_logger< LevelT >,
150 features< severity< LevelT > >
155 * Default constructor
161 severity_logger(severity_logger const& that);
163 * Constructor with named arguments
165 template< typename... ArgsT >
166 explicit severity_logger(ArgsT... const& args);
168 * The constructor creates the logger with the specified default severity level
170 * \param level The default severity level
172 explicit severity_logger(LevelT level);
174 * Assignment operator
176 severity_logger& operator= (severity_logger const& that)
180 void swap(severity_logger& that);
184 * \brief Narrow-char thread-safe logger. Functionally equivalent to \c basic_severity_logger.
186 * See \c severity class template for a more detailed description
188 template< typename LevelT = int >
189 class severity_logger_mt :
190 public basic_composite_logger<
192 severity_logger_mt< LevelT >,
193 multi_thread_model< implementation_defined >,
194 features< severity< LevelT > >
199 * Default constructor
201 severity_logger_mt();
205 severity_logger_mt(severity_logger_mt const& that);
207 * Constructor with named arguments
209 template< typename... ArgsT >
210 explicit severity_logger_mt(ArgsT... const& args);
212 * The constructor creates the logger with the specified default severity level
214 * \param level The default severity level
216 explicit severity_logger_mt(LevelT level);
218 * Assignment operator
220 severity_logger_mt& operator= (severity_logger_mt const& that)
224 void swap(severity_logger_mt& that);
228 * \brief Wide-char logger. Functionally equivalent to \c basic_severity_logger.
230 * See \c severity class template for a more detailed description
232 template< typename LevelT = int >
233 class wseverity_logger :
234 public basic_composite_logger<
236 wseverity_logger< LevelT >,
238 features< severity< LevelT > >
243 * Default constructor
249 wseverity_logger(wseverity_logger const& that);
251 * Constructor with named arguments
253 template< typename... ArgsT >
254 explicit wseverity_logger(ArgsT... const& args);
256 * The constructor creates the logger with the specified default severity level
258 * \param level The default severity level
260 explicit wseverity_logger(LevelT level);
262 * Assignment operator
264 wseverity_logger& operator= (wseverity_logger const& that)
268 void swap(wseverity_logger& that);
272 * \brief Wide-char thread-safe logger. Functionally equivalent to \c basic_severity_logger.
274 * See \c severity class template for a more detailed description
276 template< typename LevelT = int >
277 class wseverity_logger_mt :
278 public basic_composite_logger<
280 wseverity_logger_mt< LevelT >,
281 multi_thread_model< implementation_defined >,
282 features< severity< LevelT > >
287 * Default constructor
289 wseverity_logger_mt();
293 wseverity_logger_mt(wseverity_logger_mt const& that);
295 * Constructor with named arguments
297 template< typename... ArgsT >
298 explicit wseverity_logger_mt(ArgsT... const& args);
300 * The constructor creates the logger with the specified default severity level
302 * \param level The default severity level
304 explicit wseverity_logger_mt(LevelT level);
306 * Assignment operator
308 wseverity_logger_mt& operator= (wseverity_logger_mt const& that)
312 void swap(wseverity_logger_mt& that);
315 #endif // BOOST_LOG_DOXYGEN_PASS
317 } // namespace sources
319 BOOST_LOG_CLOSE_NAMESPACE // namespace log
323 #include <boost/log/detail/footer.hpp>
325 #endif // BOOST_LOG_SOURCES_SEVERITY_LOGGER_HPP_INCLUDED_