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 channel_logger.hpp
9 * \author Andrey Semashev
12 * The header contains implementation of a logger with channel support.
15 #ifndef BOOST_LOG_SOURCES_CHANNEL_LOGGER_HPP_INCLUDED_
16 #define BOOST_LOG_SOURCES_CHANNEL_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/channel_feature.hpp>
26 #include <boost/log/keywords/channel.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 channel support
44 template< typename ChannelT = std::string >
45 class channel_logger :
46 public basic_composite_logger<
48 channel_logger< ChannelT >,
50 features< channel< ChannelT > >
53 typedef typename channel_logger::logger_base base_type;
56 BOOST_LOG_FORWARD_LOGGER_MEMBERS_TEMPLATE(channel_logger)
58 explicit channel_logger(ChannelT const& channel) : base_type(keywords::channel = channel)
63 #if !defined(BOOST_LOG_NO_THREADS)
65 //! Narrow-char thread-safe logger with channel support
66 template< typename ChannelT = std::string >
67 class channel_logger_mt :
68 public basic_composite_logger<
70 channel_logger_mt< ChannelT >,
71 multi_thread_model< boost::log::aux::light_rw_mutex >,
72 features< channel< ChannelT > >
75 typedef typename channel_logger_mt::logger_base base_type;
78 BOOST_LOG_FORWARD_LOGGER_MEMBERS_TEMPLATE(channel_logger_mt)
80 explicit channel_logger_mt(ChannelT const& channel) : base_type(keywords::channel = channel)
85 #endif // !defined(BOOST_LOG_NO_THREADS)
87 #endif // BOOST_LOG_USE_CHAR
89 #ifdef BOOST_LOG_USE_WCHAR_T
91 //! Wide-char logger with channel support
92 template< typename ChannelT = std::wstring >
93 class wchannel_logger :
94 public basic_composite_logger<
96 wchannel_logger< ChannelT >,
98 features< channel< ChannelT > >
101 typedef typename wchannel_logger::logger_base base_type;
104 BOOST_LOG_FORWARD_LOGGER_MEMBERS_TEMPLATE(wchannel_logger)
106 explicit wchannel_logger(ChannelT const& channel) : base_type(keywords::channel = channel)
111 #if !defined(BOOST_LOG_NO_THREADS)
113 //! Wide-char thread-safe logger with channel support
114 template< typename ChannelT = std::wstring >
115 class wchannel_logger_mt :
116 public basic_composite_logger<
118 wchannel_logger< ChannelT >,
119 multi_thread_model< boost::log::aux::light_rw_mutex >,
120 features< channel< ChannelT > >
123 typedef typename wchannel_logger_mt::logger_base base_type;
126 BOOST_LOG_FORWARD_LOGGER_MEMBERS_TEMPLATE(wchannel_logger_mt)
128 explicit wchannel_logger_mt(ChannelT const& channel) : base_type(keywords::channel = channel)
133 #endif // !defined(BOOST_LOG_NO_THREADS)
135 #endif // BOOST_LOG_USE_WCHAR_T
137 #else // BOOST_LOG_DOXYGEN_PASS
140 * \brief Narrow-char logger. Functionally equivalent to \c basic_channel_logger.
142 * See \c channel class template for a more detailed description
144 template< typename ChannelT = std::string >
145 class channel_logger :
146 public basic_composite_logger<
148 channel_logger< ChannelT >,
150 features< channel< ChannelT > >
155 * Default constructor
161 channel_logger(channel_logger const& that);
163 * Constructor with named arguments
165 template< typename... ArgsT >
166 explicit channel_logger(ArgsT... const& args);
168 * The constructor creates the logger with the specified channel name
170 * \param channel The channel name
172 explicit channel_logger(ChannelT const& channel);
174 * Assignment operator
176 channel_logger& operator= (channel_logger const& that)
180 void swap(channel_logger& that);
184 * \brief Narrow-char thread-safe logger. Functionally equivalent to \c basic_channel_logger.
186 * See \c channel class template for a more detailed description
188 template< typename ChannelT = std::string >
189 class channel_logger_mt :
190 public basic_composite_logger<
192 channel_logger_mt< ChannelT >,
193 multi_thread_model< implementation_defined >,
194 features< channel< ChannelT > >
199 * Default constructor
205 channel_logger_mt(channel_logger_mt const& that);
207 * Constructor with named arguments
209 template< typename... ArgsT >
210 explicit channel_logger_mt(ArgsT... const& args);
212 * The constructor creates the logger with the specified channel name
214 * \param channel The channel name
216 explicit channel_logger_mt(ChannelT const& channel);
218 * Assignment operator
220 channel_logger_mt& operator= (channel_logger_mt const& that)
224 void swap(channel_logger_mt& that);
228 * \brief Wide-char logger. Functionally equivalent to \c basic_channel_logger.
230 * See \c channel class template for a more detailed description
232 template< typename ChannelT = std::wstring >
233 class wchannel_logger :
234 public basic_composite_logger<
236 wchannel_logger< ChannelT >,
238 features< channel< ChannelT > >
243 * Default constructor
249 wchannel_logger(wchannel_logger const& that);
251 * Constructor with named arguments
253 template< typename... ArgsT >
254 explicit wchannel_logger(ArgsT... const& args);
256 * The constructor creates the logger with the specified channel name
258 * \param channel The channel name
260 explicit wchannel_logger(ChannelT const& channel);
262 * Assignment operator
264 wchannel_logger& operator= (wchannel_logger const& that)
268 void swap(wchannel_logger& that);
272 * \brief Wide-char thread-safe logger. Functionally equivalent to \c basic_channel_logger.
274 * See \c channel class template for a more detailed description
276 template< typename ChannelT = std::wstring >
277 class wchannel_logger_mt :
278 public basic_composite_logger<
280 wchannel_logger< ChannelT >,
281 multi_thread_model< implementation_defined >,
282 features< channel< ChannelT > >
287 * Default constructor
289 wchannel_logger_mt();
293 wchannel_logger_mt(wchannel_logger_mt const& that);
295 * Constructor with named arguments
297 template< typename... ArgsT >
298 explicit wchannel_logger_mt(ArgsT... const& args);
300 * The constructor creates the logger with the specified channel name
302 * \param channel The channel name
304 explicit wchannel_logger_mt(ChannelT const& channel);
306 * Assignment operator
308 wchannel_logger_mt& operator= (wchannel_logger_mt const& that)
312 void swap(wchannel_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_CHANNEL_LOGGER_HPP_INCLUDED_