]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/log/sources/basic_logger.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / log / sources / basic_logger.hpp
CommitLineData
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 basic_logger.hpp
9 * \author Andrey Semashev
10 * \date 08.03.2007
11 *
12 * The header contains implementation of a base class for loggers. Convenience macros
13 * for defining custom loggers are also provided.
14 */
15
16#ifndef BOOST_LOG_SOURCES_BASIC_LOGGER_HPP_INCLUDED_
17#define BOOST_LOG_SOURCES_BASIC_LOGGER_HPP_INCLUDED_
18
19#include <exception>
20#include <utility>
21#include <ostream>
22#include <boost/assert.hpp>
23#include <boost/move/core.hpp>
24#include <boost/move/utility_core.hpp>
25#include <boost/core/addressof.hpp>
20effc67
TL
26#include <boost/type_traits/is_nothrow_swappable.hpp>
27#include <boost/type_traits/is_nothrow_move_constructible.hpp>
7c673cae
FG
28#include <boost/preprocessor/facilities/empty.hpp>
29#include <boost/preprocessor/facilities/identity.hpp>
7c673cae
FG
30#include <boost/preprocessor/seq/enum.hpp>
31#include <boost/log/detail/config.hpp>
32#include <boost/log/detail/parameter_tools.hpp>
33#include <boost/log/attributes/attribute_set.hpp>
34#include <boost/log/attributes/attribute_name.hpp>
35#include <boost/log/attributes/attribute.hpp>
36#include <boost/log/core/core.hpp>
37#include <boost/log/core/record.hpp>
38#include <boost/log/sources/features.hpp>
39#include <boost/log/sources/threading_models.hpp>
40#include <boost/log/detail/header.hpp>
41
42#ifdef BOOST_HAS_PRAGMA_ONCE
43#pragma once
44#endif
45
46namespace boost {
47
48BOOST_LOG_OPEN_NAMESPACE
49
50namespace sources {
51
52/*!
53 * \brief Basic logger class
54 *
55 * The \c basic_logger class template serves as a base class for all loggers
56 * provided by the library. It can also be used as a base for user-defined
57 * loggers. The template parameters are:
58 *
59 * \li \c CharT - logging character type
60 * \li \c FinalT - final type of the logger that eventually derives from
61 * the \c basic_logger. There may be other classes in the hierarchy
62 * between the final class and \c basic_logger.
63 * \li \c ThreadingModelT - threading model policy. Must provide methods
64 * of the Boost.Thread locking concept used in \c basic_logger class
65 * and all its derivatives in the hierarchy up to the \c FinalT class.
66 * The \c basic_logger class itself requires methods of the
67 * SharedLockable concept. The threading model policy must also be
68 * default and copy-constructible and support member function \c swap.
69 * There are currently two policies provided: \c single_thread_model
70 * and \c multi_thread_model.
71 *
72 * The logger implements fundamental facilities of loggers, such as storing
73 * source-specific attribute set and formatting log record messages. The basic
74 * logger interacts with the logging core in order to apply filtering and
75 * pass records to sinks.
76 */
77template< typename CharT, typename FinalT, typename ThreadingModelT >
78class basic_logger :
79 public ThreadingModelT
80{
81 typedef basic_logger this_type;
82 BOOST_COPYABLE_AND_MOVABLE_ALT(this_type)
83
84public:
85 //! Character type
86 typedef CharT char_type;
87 //! Final logger type
88 typedef FinalT final_type;
89 //! Threading model type
90 typedef ThreadingModelT threading_model;
91
92#if !defined(BOOST_LOG_NO_THREADS)
93 //! Lock requirement for the swap_unlocked method
20effc67 94 typedef boost::log::aux::multiple_unique_lock2< threading_model, threading_model > swap_lock;
7c673cae
FG
95 //! Lock requirement for the add_attribute_unlocked method
96 typedef boost::log::aux::exclusive_lock_guard< threading_model > add_attribute_lock;
97 //! Lock requirement for the remove_attribute_unlocked method
98 typedef boost::log::aux::exclusive_lock_guard< threading_model > remove_attribute_lock;
99 //! Lock requirement for the remove_all_attributes_unlocked method
100 typedef boost::log::aux::exclusive_lock_guard< threading_model > remove_all_attributes_lock;
101 //! Lock requirement for the get_attributes method
102 typedef boost::log::aux::shared_lock_guard< const threading_model > get_attributes_lock;
103 //! Lock requirement for the open_record_unlocked method
104 typedef boost::log::aux::shared_lock_guard< threading_model > open_record_lock;
105 //! Lock requirement for the set_attributes method
106 typedef boost::log::aux::exclusive_lock_guard< threading_model > set_attributes_lock;
107#else
108 typedef no_lock< threading_model > swap_lock;
109 typedef no_lock< threading_model > add_attribute_lock;
110 typedef no_lock< threading_model > remove_attribute_lock;
111 typedef no_lock< threading_model > remove_all_attributes_lock;
112 typedef no_lock< const threading_model > get_attributes_lock;
113 typedef no_lock< threading_model > open_record_lock;
114 typedef no_lock< threading_model > set_attributes_lock;
115#endif
116
117 //! Lock requirement for the push_record_unlocked method
118 typedef no_lock< threading_model > push_record_lock;
119
120private:
121 //! A pointer to the logging system
122 core_ptr m_pCore;
123
124 //! Logger-specific attribute set
125 attribute_set m_Attributes;
126
127public:
128 /*!
129 * Constructor. Initializes internal data structures of the basic logger class,
130 * acquires reference to the logging core.
131 */
132 basic_logger() :
133 threading_model(),
134 m_pCore(core::get())
135 {
136 }
137 /*!
138 * Copy constructor. Copies all attributes from the source logger.
139 *
140 * \note Not thread-safe. The source logger must be locked in the final class before copying.
141 *
142 * \param that Source logger
143 */
144 basic_logger(basic_logger const& that) :
145 threading_model(static_cast< threading_model const& >(that)),
20effc67 146 m_pCore(that.m_pCore),
7c673cae
FG
147 m_Attributes(that.m_Attributes)
148 {
149 }
150 /*!
151 * Move constructor. Moves all attributes from the source logger.
152 *
153 * \note Not thread-safe. The source logger must be locked in the final class before copying.
154 *
155 * \param that Source logger
156 */
20effc67
TL
157 basic_logger(BOOST_RV_REF(basic_logger) that) BOOST_NOEXCEPT_IF(boost::is_nothrow_move_constructible< threading_model >::value &&
158 boost::is_nothrow_move_constructible< core_ptr >::value &&
159 boost::is_nothrow_move_constructible< attribute_set >::value) :
160 threading_model(boost::move(static_cast< threading_model& >(that))),
161 m_pCore(boost::move(that.m_pCore)),
162 m_Attributes(boost::move(that.m_Attributes))
7c673cae 163 {
7c673cae
FG
164 }
165 /*!
166 * Constructor with named arguments. The constructor ignores all arguments. The result of
167 * construction is equivalent to default construction.
168 */
169 template< typename ArgsT >
170 explicit basic_logger(ArgsT const&) :
171 threading_model(),
172 m_pCore(core::get())
173 {
174 }
175
176protected:
177 /*!
178 * An accessor to the logging system pointer
179 */
180 core_ptr const& core() const { return m_pCore; }
181 /*!
182 * An accessor to the logger attributes
183 */
184 attribute_set& attributes() { return m_Attributes; }
185 /*!
186 * An accessor to the logger attributes
187 */
188 attribute_set const& attributes() const { return m_Attributes; }
189 /*!
190 * An accessor to the threading model base
191 */
20effc67 192 threading_model& get_threading_model() BOOST_NOEXCEPT { return *this; }
7c673cae
FG
193 /*!
194 * An accessor to the threading model base
195 */
20effc67 196 threading_model const& get_threading_model() const BOOST_NOEXCEPT { return *this; }
7c673cae
FG
197 /*!
198 * An accessor to the final logger
199 */
20effc67 200 final_type* final_this() BOOST_NOEXCEPT
7c673cae
FG
201 {
202 BOOST_LOG_ASSUME(this != NULL);
203 return static_cast< final_type* >(this);
204 }
205 /*!
206 * An accessor to the final logger
207 */
20effc67 208 final_type const* final_this() const BOOST_NOEXCEPT
7c673cae
FG
209 {
210 BOOST_LOG_ASSUME(this != NULL);
211 return static_cast< final_type const* >(this);
212 }
213
214 /*!
215 * Unlocked \c swap
216 */
217 void swap_unlocked(basic_logger& that)
218 {
219 get_threading_model().swap(that.get_threading_model());
220 m_Attributes.swap(that.m_Attributes);
221 }
222
223 /*!
224 * Unlocked \c add_attribute
225 */
226 std::pair< attribute_set::iterator, bool > add_attribute_unlocked(attribute_name const& name, attribute const& attr)
227 {
228 return m_Attributes.insert(name, attr);
229 }
230
231 /*!
232 * Unlocked \c remove_attribute
233 */
234 void remove_attribute_unlocked(attribute_set::iterator it)
235 {
236 m_Attributes.erase(it);
237 }
238
239 /*!
240 * Unlocked \c remove_all_attributes
241 */
242 void remove_all_attributes_unlocked()
243 {
244 m_Attributes.clear();
245 }
246
247 /*!
248 * Unlocked \c open_record
249 */
250 record open_record_unlocked()
251 {
252 return m_pCore->open_record(m_Attributes);
253 }
254 /*!
255 * Unlocked \c open_record
256 */
257 template< typename ArgsT >
258 record open_record_unlocked(ArgsT const&)
259 {
260 return m_pCore->open_record(m_Attributes);
261 }
262
263 /*!
264 * Unlocked \c push_record
265 */
266 void push_record_unlocked(BOOST_RV_REF(record) rec)
267 {
268 m_pCore->push_record(boost::move(rec));
269 }
270
271 /*!
272 * Unlocked \c get_attributes
273 */
274 attribute_set get_attributes_unlocked() const
275 {
276 return m_Attributes;
277 }
278
279 /*!
280 * Unlocked \c set_attributes
281 */
282 void set_attributes_unlocked(attribute_set const& attrs)
283 {
284 m_Attributes = attrs;
285 }
286
287 //! Assignment is closed (should be implemented through copy and swap in the final class)
288 BOOST_DELETED_FUNCTION(basic_logger& operator= (basic_logger const&))
289};
290
291/*!
292 * Free-standing swap for all loggers
293 */
294template< typename CharT, typename FinalT, typename ThreadingModelT >
295inline void swap(
296 basic_logger< CharT, FinalT, ThreadingModelT >& left,
20effc67 297 basic_logger< CharT, FinalT, ThreadingModelT >& right) BOOST_NOEXCEPT_IF(boost::is_nothrow_swappable< FinalT >::value)
7c673cae
FG
298{
299 static_cast< FinalT& >(left).swap(static_cast< FinalT& >(right));
300}
301
302/*!
303 * \brief A composite logger that inherits a number of features
304 *
305 * The composite logger is a helper class that simplifies feature composition into the final logger.
306 * The user's logger class is expected to derive from the composite logger class, instantiated with
307 * the character type, the user's logger class, the threading model and the list of the required features.
308 * The former three parameters are passed to the \c basic_logger class template. The feature list
309 * must be an MPL type sequence, where each element is a unary MPL metafunction class, that upon
310 * applying on its argument results in a logging feature class that derives from the argument.
311 * Every logger feature provided by the library can participate in the feature list.
312 */
313template< typename CharT, typename FinalT, typename ThreadingModelT, typename FeaturesT >
314class basic_composite_logger :
315 public boost::log::sources::aux::inherit_features<
316 basic_logger< CharT, FinalT, ThreadingModelT >,
317 FeaturesT
318 >::type
319{
320private:
321 //! Base type (the hierarchy of features)
322 typedef typename boost::log::sources::aux::inherit_features<
323 basic_logger< CharT, FinalT, ThreadingModelT >,
324 FeaturesT
325 >::type base_type;
326
327protected:
328 //! The composite logger type (for use in the user's logger class)
329 typedef basic_composite_logger logger_base;
330 BOOST_COPYABLE_AND_MOVABLE_ALT(logger_base)
331
332public:
333 //! Threading model being used
334 typedef typename base_type::threading_model threading_model;
335
20effc67
TL
336 //! Lock requirement for the swap_unlocked method
337 typedef typename base_type::swap_lock swap_lock;
338
7c673cae
FG
339#if !defined(BOOST_LOG_NO_THREADS)
340
341public:
342 /*!
343 * Default constructor (default-constructs all features)
344 */
345 basic_composite_logger() {}
346 /*!
347 * Copy constructor
348 */
349 basic_composite_logger(basic_composite_logger const& that) :
350 base_type
351 ((
352 boost::log::aux::shared_lock_guard< const threading_model >(that.get_threading_model()),
353 static_cast< base_type const& >(that)
354 ))
355 {
356 }
357 /*!
358 * Move constructor
359 */
20effc67 360 basic_composite_logger(BOOST_RV_REF(logger_base) that) BOOST_NOEXCEPT_IF(boost::is_nothrow_move_constructible< base_type >::value) :
7c673cae
FG
361 base_type(boost::move(static_cast< base_type& >(that)))
362 {
363 }
364 /*!
365 * Constructor with named parameters
366 */
367 template< typename ArgsT >
368 explicit basic_composite_logger(ArgsT const& args) : base_type(args)
369 {
370 }
371
372 /*!
373 * The method adds an attribute to the source-specific attribute set. The attribute will be implicitly added to
374 * every log record made with the current logger.
375 *
376 * \param name The attribute name.
377 * \param attr The attribute factory.
378 * \return A pair of values. If the second member is \c true, then the attribute is added and the first member points to the
379 * attribute. Otherwise the attribute was not added and the first member points to the attribute that prevents
380 * addition.
381 */
382 std::pair< attribute_set::iterator, bool > add_attribute(attribute_name const& name, attribute const& attr)
383 {
384 typename base_type::add_attribute_lock lock(base_type::get_threading_model());
385 return base_type::add_attribute_unlocked(name, attr);
386 }
387 /*!
388 * The method removes an attribute from the source-specific attribute set.
389 *
390 * \pre The attribute was added with the add_attribute call for this instance of the logger.
391 * \post The attribute is no longer registered as a source-specific attribute for this logger. The iterator is invalidated after removal.
392 *
393 * \param it Iterator to the previously added attribute.
394 */
395 void remove_attribute(attribute_set::iterator it)
396 {
397 typename base_type::remove_attribute_lock lock(base_type::get_threading_model());
398 base_type::remove_attribute_unlocked(it);
399 }
400
401 /*!
402 * The method removes all attributes from the logger. All iterators and references to the removed attributes are invalidated.
403 */
404 void remove_all_attributes()
405 {
406 typename base_type::remove_all_attributes_lock lock(base_type::get_threading_model());
407 base_type::remove_all_attributes_unlocked();
408 }
409
410 /*!
411 * The method retrieves a copy of a set with all attributes from the logger.
412 *
413 * \return The copy of the attribute set. Attributes are shallow-copied.
414 */
415 attribute_set get_attributes() const
416 {
417 typename base_type::get_attributes_lock lock(base_type::get_threading_model());
418 return base_type::get_attributes_unlocked();
419 }
420
421 /*!
422 * The method installs the whole attribute set into the logger. All iterators and references to elements of
423 * the previous set are invalidated. Iterators to the \a attrs set are not valid to be used with the logger (that is,
424 * the logger owns a copy of \a attrs after completion).
425 *
426 * \param attrs The set of attributes to install into the logger. Attributes are shallow-copied.
427 */
428 void set_attributes(attribute_set const& attrs)
429 {
430 typename base_type::set_attributes_lock lock(base_type::get_threading_model());
431 base_type::set_attributes_unlocked(attrs);
432 }
433
434 /*!
435 * The method opens a new log record in the logging core.
436 *
437 * \return A valid record handle if the logging record is opened successfully, an invalid handle otherwise.
438 */
439 record open_record()
440 {
441 // Perform a quick check first
442 if (this->core()->get_logging_enabled())
443 {
444 typename base_type::open_record_lock lock(base_type::get_threading_model());
445 return base_type::open_record_unlocked(boost::log::aux::empty_arg_list());
446 }
447 else
448 return record();
449 }
450 /*!
451 * The method opens a new log record in the logging core.
452 *
453 * \param args A set of additional named arguments. The parameter is ignored.
454 * \return A valid record handle if the logging record is opened successfully, an invalid handle otherwise.
455 */
456 template< typename ArgsT >
457 record open_record(ArgsT const& args)
458 {
459 // Perform a quick check first
460 if (this->core()->get_logging_enabled())
461 {
462 typename base_type::open_record_lock lock(base_type::get_threading_model());
463 return base_type::open_record_unlocked(args);
464 }
465 else
466 return record();
467 }
468 /*!
469 * The method pushes the constructed message to the logging core
470 *
471 * \param rec The log record with the formatted message
472 */
473 void push_record(BOOST_RV_REF(record) rec)
474 {
475 typename base_type::push_record_lock lock(base_type::get_threading_model());
476 base_type::push_record_unlocked(boost::move(rec));
477 }
478 /*!
479 * Thread-safe implementation of swap
480 */
481 void swap(basic_composite_logger& that)
482 {
20effc67
TL
483 swap_lock lock(base_type::get_threading_model(), that.get_threading_model());
484 base_type::swap_unlocked(static_cast< base_type& >(that));
7c673cae
FG
485 }
486
487protected:
488 /*!
489 * Assignment for the final class. Threadsafe, provides strong exception guarantee.
490 */
491 FinalT& assign(FinalT const& that)
492 {
493 BOOST_LOG_ASSUME(this != NULL);
494 if (static_cast< FinalT* >(this) != boost::addressof(that))
495 {
496 // We'll have to explicitly create the copy in order to make sure it's unlocked when we attempt to lock *this
497 FinalT tmp(that);
498 boost::log::aux::exclusive_lock_guard< threading_model > lock(base_type::get_threading_model());
499 base_type::swap_unlocked(tmp);
500 }
501 return static_cast< FinalT& >(*this);
502 }
503};
504
505//! An optimized composite logger version with no multithreading support
506template< typename CharT, typename FinalT, typename FeaturesT >
507class basic_composite_logger< CharT, FinalT, single_thread_model, FeaturesT > :
508 public boost::log::sources::aux::inherit_features<
509 basic_logger< CharT, FinalT, single_thread_model >,
510 FeaturesT
511 >::type
512{
513private:
514 typedef typename boost::log::sources::aux::inherit_features<
515 basic_logger< CharT, FinalT, single_thread_model >,
516 FeaturesT
517 >::type base_type;
518
519protected:
520 typedef basic_composite_logger logger_base;
521 BOOST_COPYABLE_AND_MOVABLE_ALT(logger_base)
522
523public:
524 typedef typename base_type::threading_model threading_model;
525
526#endif // !defined(BOOST_LOG_NO_THREADS)
527
528public:
529 basic_composite_logger() {}
530 basic_composite_logger(basic_composite_logger const& that) :
531 base_type(static_cast< base_type const& >(that))
532 {
533 }
20effc67 534 basic_composite_logger(BOOST_RV_REF(logger_base) that) BOOST_NOEXCEPT_IF(boost::is_nothrow_move_constructible< base_type >::value) :
7c673cae
FG
535 base_type(boost::move(static_cast< base_type& >(that)))
536 {
537 }
538 template< typename ArgsT >
539 explicit basic_composite_logger(ArgsT const& args) : base_type(args)
540 {
541 }
542
543 std::pair< attribute_set::iterator, bool > add_attribute(attribute_name const& name, attribute const& attr)
544 {
545 return base_type::add_attribute_unlocked(name, attr);
546 }
547 void remove_attribute(attribute_set::iterator it)
548 {
549 base_type::remove_attribute_unlocked(it);
550 }
551 void remove_all_attributes()
552 {
553 base_type::remove_all_attributes_unlocked();
554 }
555 attribute_set get_attributes() const
556 {
557 return base_type::get_attributes_unlocked();
558 }
559 void set_attributes(attribute_set const& attrs)
560 {
561 base_type::set_attributes_unlocked(attrs);
562 }
563 record open_record()
564 {
565 // Perform a quick check first
566 if (this->core()->get_logging_enabled())
567 return base_type::open_record_unlocked(boost::log::aux::empty_arg_list());
568 else
569 return record();
570 }
571 template< typename ArgsT >
572 record open_record(ArgsT const& args)
573 {
574 // Perform a quick check first
575 if (this->core()->get_logging_enabled())
576 return base_type::open_record_unlocked(args);
577 else
578 return record();
579 }
580 void push_record(BOOST_RV_REF(record) rec)
581 {
582 base_type::push_record_unlocked(boost::move(rec));
583 }
584 void swap(basic_composite_logger& that)
585 {
20effc67 586 base_type::swap_unlocked(static_cast< base_type& >(that));
7c673cae
FG
587 }
588
589protected:
590 FinalT& assign(FinalT that)
591 {
592 base_type::swap_unlocked(that);
593 return static_cast< FinalT& >(*this);
594 }
595};
596
597
598#ifndef BOOST_LOG_DOXYGEN_PASS
599
600#define BOOST_LOG_FORWARD_LOGGER_CONSTRUCTORS_IMPL(class_type, typename_keyword)\
601 public:\
602 BOOST_DEFAULTED_FUNCTION(class_type(), {})\
603 class_type(class_type const& that) : class_type::logger_base(\
604 static_cast< typename_keyword() class_type::logger_base const& >(that)) {}\
20effc67 605 class_type(BOOST_RV_REF(class_type) that) BOOST_NOEXCEPT_IF(boost::is_nothrow_move_constructible< typename_keyword() class_type::logger_base >::value) : class_type::logger_base(\
7c673cae
FG
606 ::boost::move(static_cast< typename_keyword() class_type::logger_base& >(that))) {}\
607 BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_FORWARD(class_type, class_type::logger_base)\
608
609#endif // BOOST_LOG_DOXYGEN_PASS
610
611#define BOOST_LOG_FORWARD_LOGGER_CONSTRUCTORS(class_type)\
612 BOOST_LOG_FORWARD_LOGGER_CONSTRUCTORS_IMPL(class_type, BOOST_PP_EMPTY)
613
614#define BOOST_LOG_FORWARD_LOGGER_CONSTRUCTORS_TEMPLATE(class_type)\
615 BOOST_LOG_FORWARD_LOGGER_CONSTRUCTORS_IMPL(class_type, BOOST_PP_IDENTITY(typename))
616
617#define BOOST_LOG_FORWARD_LOGGER_ASSIGNMENT(class_type)\
618 public:\
619 class_type& operator= (BOOST_COPY_ASSIGN_REF(class_type) that)\
620 {\
621 return class_type::logger_base::assign(static_cast< class_type const& >(that));\
622 }\
623 class_type& operator= (BOOST_RV_REF(class_type) that)\
624 {\
625 BOOST_LOG_EXPR_IF_MT(::boost::log::aux::exclusive_lock_guard< class_type::threading_model > lock(this->get_threading_model());)\
626 this->swap_unlocked(that);\
627 return *this;\
628 }
629
630#define BOOST_LOG_FORWARD_LOGGER_ASSIGNMENT_TEMPLATE(class_type)\
631 public:\
632 class_type& operator= (BOOST_COPY_ASSIGN_REF(class_type) that)\
633 {\
634 return class_type::logger_base::assign(static_cast< class_type const& >(that));\
635 }\
636 class_type& operator= (BOOST_RV_REF(class_type) that)\
637 {\
638 BOOST_LOG_EXPR_IF_MT(::boost::log::aux::exclusive_lock_guard< typename class_type::threading_model > lock(this->get_threading_model());)\
639 this->swap_unlocked(that);\
640 return *this;\
641 }
642
643#define BOOST_LOG_FORWARD_LOGGER_MEMBERS(class_type)\
644 BOOST_COPYABLE_AND_MOVABLE(class_type)\
645 BOOST_LOG_FORWARD_LOGGER_CONSTRUCTORS(class_type)\
646 BOOST_LOG_FORWARD_LOGGER_ASSIGNMENT(class_type)
647
648#define BOOST_LOG_FORWARD_LOGGER_MEMBERS_TEMPLATE(class_type)\
649 BOOST_COPYABLE_AND_MOVABLE(class_type)\
650 BOOST_LOG_FORWARD_LOGGER_CONSTRUCTORS_TEMPLATE(class_type)\
651 BOOST_LOG_FORWARD_LOGGER_ASSIGNMENT_TEMPLATE(class_type)
652
653} // namespace sources
654
655BOOST_LOG_CLOSE_NAMESPACE // namespace log
656
657} // namespace boost
658
659/*!
660 * \brief The macro declares a logger class that inherits a number of base classes
661 *
662 * \param type_name The name of the logger class to declare
663 * \param char_type The character type of the logger. Either char or wchar_t expected.
664 * \param base_seq A Boost.Preprocessor sequence of type identifiers of the base classes templates
665 * \param threading A threading model class
666 */
667#define BOOST_LOG_DECLARE_LOGGER_TYPE(type_name, char_type, base_seq, threading)\
668 class type_name :\
669 public ::boost::log::sources::basic_composite_logger<\
670 char_type,\
671 type_name,\
672 threading,\
673 ::boost::log::sources::features< BOOST_PP_SEQ_ENUM(base_seq) >\
674 >\
675 {\
676 BOOST_LOG_FORWARD_LOGGER_MEMBERS(type_name)\
677 }
678
679
680
681#ifdef BOOST_LOG_USE_CHAR
682
683/*!
684 * \brief The macro declares a narrow-char logger class that inherits a number of base classes
685 *
686 * Equivalent to BOOST_LOG_DECLARE_LOGGER_TYPE(type_name, char, base_seq, single_thread_model)
687 *
688 * \param type_name The name of the logger class to declare
689 * \param base_seq A Boost.Preprocessor sequence of type identifiers of the base classes templates
690 */
691#define BOOST_LOG_DECLARE_LOGGER(type_name, base_seq)\
692 BOOST_LOG_DECLARE_LOGGER_TYPE(type_name, char, base_seq, ::boost::log::sources::single_thread_model)
693
694#if !defined(BOOST_LOG_NO_THREADS)
695
696/*!
697 * \brief The macro declares a narrow-char thread-safe logger class that inherits a number of base classes
698 *
699 * Equivalent to <tt>BOOST_LOG_DECLARE_LOGGER_TYPE(type_name, char, base_seq, multi_thread_model< shared_mutex >)</tt>
700 *
701 * \param type_name The name of the logger class to declare
702 * \param base_seq A Boost.Preprocessor sequence of type identifiers of the base classes templates
703 */
704#define BOOST_LOG_DECLARE_LOGGER_MT(type_name, base_seq)\
705 BOOST_LOG_DECLARE_LOGGER_TYPE(type_name, char, base_seq,\
706 ::boost::log::sources::multi_thread_model< ::boost::shared_mutex >)
707
708#endif // !defined(BOOST_LOG_NO_THREADS)
709#endif // BOOST_LOG_USE_CHAR
710
711#ifdef BOOST_LOG_USE_WCHAR_T
712
713/*!
714 * \brief The macro declares a wide-char logger class that inherits a number of base classes
715 *
716 * Equivalent to BOOST_LOG_DECLARE_LOGGER_TYPE(type_name, wchar_t, base_seq, single_thread_model)
717 *
718 * \param type_name The name of the logger class to declare
719 * \param base_seq A Boost.Preprocessor sequence of type identifiers of the base classes templates
720 */
721#define BOOST_LOG_DECLARE_WLOGGER(type_name, base_seq)\
722 BOOST_LOG_DECLARE_LOGGER_TYPE(type_name, wchar_t, base_seq, ::boost::log::sources::single_thread_model)
723
724#if !defined(BOOST_LOG_NO_THREADS)
725
726/*!
727 * \brief The macro declares a wide-char thread-safe logger class that inherits a number of base classes
728 *
729 * Equivalent to <tt>BOOST_LOG_DECLARE_LOGGER_TYPE(type_name, wchar_t, base_seq, multi_thread_model< shared_mutex >)</tt>
730 *
731 * \param type_name The name of the logger class to declare
732 * \param base_seq A Boost.Preprocessor sequence of type identifiers of the base classes templates
733 */
734#define BOOST_LOG_DECLARE_WLOGGER_MT(type_name, base_seq)\
735 BOOST_LOG_DECLARE_LOGGER_TYPE(type_name, wchar_t, base_seq,\
736 ::boost::log::sources::multi_thread_model< ::boost::shared_mutex >)
737
738#endif // !defined(BOOST_LOG_NO_THREADS)
739#endif // BOOST_LOG_USE_WCHAR_T
740
741#include <boost/log/detail/footer.hpp>
742
743#endif // BOOST_LOG_SOURCES_BASIC_LOGGER_HPP_INCLUDED_