]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /* |
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) | |
6 | */ | |
7 | /*! | |
8 | * \file severity_logger.hpp | |
9 | * \author Andrey Semashev | |
10 | * \date 08.03.2007 | |
11 | * | |
12 | * The header contains implementation of a logger with severity level support. | |
13 | */ | |
14 | ||
15 | #ifndef BOOST_LOG_SOURCES_SEVERITY_LOGGER_HPP_INCLUDED_ | |
16 | #define BOOST_LOG_SOURCES_SEVERITY_LOGGER_HPP_INCLUDED_ | |
17 | ||
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> | |
28 | ||
29 | #ifdef BOOST_HAS_PRAGMA_ONCE | |
30 | #pragma once | |
31 | #endif | |
32 | ||
33 | namespace boost { | |
34 | ||
35 | BOOST_LOG_OPEN_NAMESPACE | |
36 | ||
37 | namespace sources { | |
38 | ||
39 | #ifndef BOOST_LOG_DOXYGEN_PASS | |
40 | ||
41 | #ifdef BOOST_LOG_USE_CHAR | |
42 | ||
43 | //! Narrow-char logger with severity level support | |
44 | template< typename LevelT = int > | |
45 | class severity_logger : | |
46 | public basic_composite_logger< | |
47 | char, | |
48 | severity_logger< LevelT >, | |
49 | single_thread_model, | |
50 | features< severity< LevelT > > | |
51 | > | |
52 | { | |
53 | typedef typename severity_logger::logger_base base_type; | |
54 | ||
55 | public: | |
56 | BOOST_LOG_FORWARD_LOGGER_MEMBERS_TEMPLATE(severity_logger) | |
57 | ||
58 | explicit severity_logger(LevelT level) : base_type(keywords::severity = level) | |
59 | { | |
60 | } | |
61 | }; | |
62 | ||
63 | #if !defined(BOOST_LOG_NO_THREADS) | |
64 | ||
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< | |
69 | char, | |
70 | severity_logger_mt< LevelT >, | |
71 | multi_thread_model< boost::log::aux::light_rw_mutex >, | |
72 | features< severity< LevelT > > | |
73 | > | |
74 | { | |
75 | typedef typename severity_logger_mt::logger_base base_type; | |
76 | ||
77 | public: | |
78 | BOOST_LOG_FORWARD_LOGGER_MEMBERS_TEMPLATE(severity_logger_mt) | |
79 | ||
80 | explicit severity_logger_mt(LevelT level) : base_type(keywords::severity = level) | |
81 | { | |
82 | } | |
83 | }; | |
84 | ||
85 | #endif // !defined(BOOST_LOG_NO_THREADS) | |
86 | ||
87 | #endif | |
88 | ||
89 | #ifdef BOOST_LOG_USE_WCHAR_T | |
90 | ||
91 | //! Wide-char logger with severity level support | |
92 | template< typename LevelT = int > | |
93 | class wseverity_logger : | |
94 | public basic_composite_logger< | |
95 | wchar_t, | |
96 | wseverity_logger< LevelT >, | |
97 | single_thread_model, | |
98 | features< severity< LevelT > > | |
99 | > | |
100 | { | |
101 | typedef typename wseverity_logger::logger_base base_type; | |
102 | ||
103 | public: | |
104 | BOOST_LOG_FORWARD_LOGGER_MEMBERS_TEMPLATE(wseverity_logger) | |
105 | ||
106 | explicit wseverity_logger(LevelT level) : base_type(keywords::severity = level) | |
107 | { | |
108 | } | |
109 | }; | |
110 | ||
111 | #if !defined(BOOST_LOG_NO_THREADS) | |
112 | ||
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< | |
117 | wchar_t, | |
118 | wseverity_logger_mt< LevelT >, | |
119 | multi_thread_model< boost::log::aux::light_rw_mutex >, | |
120 | features< severity< LevelT > > | |
121 | > | |
122 | { | |
123 | typedef typename wseverity_logger_mt::logger_base base_type; | |
124 | ||
125 | public: | |
126 | BOOST_LOG_FORWARD_LOGGER_MEMBERS_TEMPLATE(wseverity_logger_mt) | |
127 | ||
128 | explicit wseverity_logger_mt(LevelT level) : base_type(keywords::severity = level) | |
129 | { | |
130 | } | |
131 | }; | |
132 | ||
133 | #endif // !defined(BOOST_LOG_NO_THREADS) | |
134 | ||
135 | #endif | |
136 | ||
137 | #else // BOOST_LOG_DOXYGEN_PASS | |
138 | ||
139 | /*! | |
140 | * \brief Narrow-char logger. Functionally equivalent to \c basic_severity_logger. | |
141 | * | |
142 | * See \c severity class template for a more detailed description | |
143 | */ | |
144 | template< typename LevelT = int > | |
145 | class severity_logger : | |
146 | public basic_composite_logger< | |
147 | char, | |
148 | severity_logger< LevelT >, | |
149 | single_thread_model, | |
150 | features< severity< LevelT > > | |
151 | > | |
152 | { | |
153 | public: | |
154 | /*! | |
155 | * Default constructor | |
156 | */ | |
157 | severity_logger(); | |
158 | /*! | |
159 | * Copy constructor | |
160 | */ | |
161 | severity_logger(severity_logger const& that); | |
162 | /*! | |
163 | * Constructor with named arguments | |
164 | */ | |
165 | template< typename... ArgsT > | |
166 | explicit severity_logger(ArgsT... const& args); | |
167 | /*! | |
168 | * The constructor creates the logger with the specified default severity level | |
169 | * | |
170 | * \param level The default severity level | |
171 | */ | |
172 | explicit severity_logger(LevelT level); | |
173 | /*! | |
174 | * Assignment operator | |
175 | */ | |
176 | severity_logger& operator= (severity_logger const& that) | |
177 | /*! | |
178 | * Swaps two loggers | |
179 | */ | |
180 | void swap(severity_logger& that); | |
181 | }; | |
182 | ||
183 | /*! | |
184 | * \brief Narrow-char thread-safe logger. Functionally equivalent to \c basic_severity_logger. | |
185 | * | |
186 | * See \c severity class template for a more detailed description | |
187 | */ | |
188 | template< typename LevelT = int > | |
189 | class severity_logger_mt : | |
190 | public basic_composite_logger< | |
191 | char, | |
192 | severity_logger_mt< LevelT >, | |
193 | multi_thread_model< implementation_defined >, | |
194 | features< severity< LevelT > > | |
195 | > | |
196 | { | |
197 | public: | |
198 | /*! | |
199 | * Default constructor | |
200 | */ | |
201 | severity_logger_mt(); | |
202 | /*! | |
203 | * Copy constructor | |
204 | */ | |
205 | severity_logger_mt(severity_logger_mt const& that); | |
206 | /*! | |
207 | * Constructor with named arguments | |
208 | */ | |
209 | template< typename... ArgsT > | |
210 | explicit severity_logger_mt(ArgsT... const& args); | |
211 | /*! | |
212 | * The constructor creates the logger with the specified default severity level | |
213 | * | |
214 | * \param level The default severity level | |
215 | */ | |
216 | explicit severity_logger_mt(LevelT level); | |
217 | /*! | |
218 | * Assignment operator | |
219 | */ | |
220 | severity_logger_mt& operator= (severity_logger_mt const& that) | |
221 | /*! | |
222 | * Swaps two loggers | |
223 | */ | |
224 | void swap(severity_logger_mt& that); | |
225 | }; | |
226 | ||
227 | /*! | |
228 | * \brief Wide-char logger. Functionally equivalent to \c basic_severity_logger. | |
229 | * | |
230 | * See \c severity class template for a more detailed description | |
231 | */ | |
232 | template< typename LevelT = int > | |
233 | class wseverity_logger : | |
234 | public basic_composite_logger< | |
235 | wchar_t, | |
236 | wseverity_logger< LevelT >, | |
237 | single_thread_model, | |
238 | features< severity< LevelT > > | |
239 | > | |
240 | { | |
241 | public: | |
242 | /*! | |
243 | * Default constructor | |
244 | */ | |
245 | wseverity_logger(); | |
246 | /*! | |
247 | * Copy constructor | |
248 | */ | |
249 | wseverity_logger(wseverity_logger const& that); | |
250 | /*! | |
251 | * Constructor with named arguments | |
252 | */ | |
253 | template< typename... ArgsT > | |
254 | explicit wseverity_logger(ArgsT... const& args); | |
255 | /*! | |
256 | * The constructor creates the logger with the specified default severity level | |
257 | * | |
258 | * \param level The default severity level | |
259 | */ | |
260 | explicit wseverity_logger(LevelT level); | |
261 | /*! | |
262 | * Assignment operator | |
263 | */ | |
264 | wseverity_logger& operator= (wseverity_logger const& that) | |
265 | /*! | |
266 | * Swaps two loggers | |
267 | */ | |
268 | void swap(wseverity_logger& that); | |
269 | }; | |
270 | ||
271 | /*! | |
272 | * \brief Wide-char thread-safe logger. Functionally equivalent to \c basic_severity_logger. | |
273 | * | |
274 | * See \c severity class template for a more detailed description | |
275 | */ | |
276 | template< typename LevelT = int > | |
277 | class wseverity_logger_mt : | |
278 | public basic_composite_logger< | |
279 | wchar_t, | |
280 | wseverity_logger_mt< LevelT >, | |
281 | multi_thread_model< implementation_defined >, | |
282 | features< severity< LevelT > > | |
283 | > | |
284 | { | |
285 | public: | |
286 | /*! | |
287 | * Default constructor | |
288 | */ | |
289 | wseverity_logger_mt(); | |
290 | /*! | |
291 | * Copy constructor | |
292 | */ | |
293 | wseverity_logger_mt(wseverity_logger_mt const& that); | |
294 | /*! | |
295 | * Constructor with named arguments | |
296 | */ | |
297 | template< typename... ArgsT > | |
298 | explicit wseverity_logger_mt(ArgsT... const& args); | |
299 | /*! | |
300 | * The constructor creates the logger with the specified default severity level | |
301 | * | |
302 | * \param level The default severity level | |
303 | */ | |
304 | explicit wseverity_logger_mt(LevelT level); | |
305 | /*! | |
306 | * Assignment operator | |
307 | */ | |
308 | wseverity_logger_mt& operator= (wseverity_logger_mt const& that) | |
309 | /*! | |
310 | * Swaps two loggers | |
311 | */ | |
312 | void swap(wseverity_logger_mt& that); | |
313 | }; | |
314 | ||
315 | #endif // BOOST_LOG_DOXYGEN_PASS | |
316 | ||
317 | } // namespace sources | |
318 | ||
319 | BOOST_LOG_CLOSE_NAMESPACE // namespace log | |
320 | ||
321 | } // namespace boost | |
322 | ||
323 | #include <boost/log/detail/footer.hpp> | |
324 | ||
325 | #endif // BOOST_LOG_SOURCES_SEVERITY_LOGGER_HPP_INCLUDED_ |