...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::log::sources::basic_logger — Basic logger class.
// In header: <boost/log/sources/basic_logger.hpp> template<typename CharT, typename FinalT, typename ThreadingModelT> class basic_logger : public ThreadingModelT { public: // types typedef CharT char_type; // Character type. typedef FinalT final_type; // Final logger type. typedef ThreadingModelT threading_model; // Threading model type. typedef unspecified swap_lock; // Lock requirement for the swap_unlocked method. typedef unspecified add_attribute_lock; // Lock requirement for the add_attribute_unlocked method. typedef unspecified remove_attribute_lock; // Lock requirement for the remove_attribute_unlocked method. typedef unspecified remove_all_attributes_lock; // Lock requirement for the remove_all_attributes_unlocked method. typedef unspecified get_attributes_lock; // Lock requirement for the get_attributes method. typedef unspecified open_record_lock; // Lock requirement for the open_record_unlocked method. typedef unspecified set_attributes_lock; // Lock requirement for the set_attributes method. typedef no_lock< threading_model > push_record_lock; // Lock requirement for the push_record_unlocked method. // construct/copy/destruct basic_logger(); basic_logger(basic_logger const &); basic_logger(basic_logger &&); template<typename ArgsT> explicit basic_logger(ArgsT const &); basic_logger & operator=(basic_logger const &) = delete; // protected member functions core_ptr const & core() const; attribute_set & attributes(); attribute_set const & attributes() const; threading_model & get_threading_model(); threading_model const & get_threading_model() const; final_type * final_this(); final_type const * final_this() const; void swap_unlocked(basic_logger &); std::pair< attribute_set::iterator, bool > add_attribute_unlocked(attribute_name const &, attribute const &); void remove_attribute_unlocked(attribute_set::iterator); void remove_all_attributes_unlocked(); record open_record_unlocked(); template<typename ArgsT> record open_record_unlocked(ArgsT const &); void push_record_unlocked(record &&); attribute_set get_attributes_unlocked() const; void set_attributes_unlocked(attribute_set const &); };
The basic_logger
class template serves as a base class for all loggers provided by the library. It can also be used as a base for user-defined loggers. The template parameters are:
CharT
- logging character type
FinalT
- final type of the logger that eventually derives from the basic_logger
. There may be other classes in the hierarchy between the final class and basic_logger
.
ThreadingModelT
- threading model policy. Must provide methods of the Boost.Thread locking concept used in basic_logger
class and all its derivatives in the hierarchy up to the FinalT
class. The basic_logger
class itself requires methods of the SharedLockable concept. The threading model policy must also be default and copy-constructible and support member function swap
. There are currently two policies provided: single_thread_model
and multi_thread_model
.
The logger implements fundamental facilities of loggers, such as storing source-specific attribute set and formatting log record messages. The basic logger interacts with the logging core in order to apply filtering and pass records to sinks.
basic_logger
public
construct/copy/destructbasic_logger();
Constructor. Initializes internal data structures of the basic logger class, acquires reference to the logging core.
basic_logger(basic_logger const & that);
Copy constructor. Copies all attributes from the source logger.
Note | |
---|---|
Not thread-safe. The source logger must be locked in the final class before copying. |
Parameters: |
|
basic_logger(basic_logger && that);
Move constructor. Moves all attributes from the source logger.
Note | |
---|---|
Not thread-safe. The source logger must be locked in the final class before copying. |
Parameters: |
|
template<typename ArgsT> explicit basic_logger(ArgsT const &);
Constructor with named arguments. The constructor ignores all arguments. The result of construction is equivalent to default construction.
basic_logger & operator=(basic_logger const &) = delete;Assignment is closed (should be implemented through copy and swap in the final class)
basic_logger
protected member functionscore_ptr const & core() const;
An accessor to the logging system pointer
attribute_set & attributes();
An accessor to the logger attributes
attribute_set const & attributes() const;
An accessor to the logger attributes
threading_model & get_threading_model();
An accessor to the threading model base
threading_model const & get_threading_model() const;
An accessor to the threading model base
final_type * final_this();
An accessor to the final logger
final_type const * final_this() const;
An accessor to the final logger
void swap_unlocked(basic_logger & that);
Unlocked swap
std::pair< attribute_set::iterator, bool > add_attribute_unlocked(attribute_name const & name, attribute const & attr);
Unlocked add_attribute
void remove_attribute_unlocked(attribute_set::iterator it);
Unlocked remove_attribute
void remove_all_attributes_unlocked();
Unlocked remove_all_attributes
record open_record_unlocked();
Unlocked open_record
template<typename ArgsT> record open_record_unlocked(ArgsT const &);
Unlocked open_record
void push_record_unlocked(record && rec);
Unlocked push_record
attribute_set get_attributes_unlocked() const;
Unlocked get_attributes
void set_attributes_unlocked(attribute_set const & attrs);
Unlocked set_attributes