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: // types typedef CharT char_type; // Character type. typedef FinalT final_type; // Final logger type. typedef std::basic_string< char_type > string_type; // String type to be used as a message text holder. typedef basic_attribute_set< char_type > attribute_set_type; // Attribute set type. typedef basic_core< char_type > core_type; // Logging system core type. typedef basic_record< char_type > record_type; // Logging record type. typedef ThreadingModelT threading_model; // Threading model type. typedef lock_guard< threading_model > swap_lock; // Lock requirement for the swap_unlocked method. typedef lock_guard< threading_model > add_attribute_lock; // Lock requirement for the add_attribute_unlocked method. typedef lock_guard< threading_model > remove_attribute_lock; // Lock requirement for the remove_attribute_unlocked method. typedef lock_guard< threading_model > 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 lock_guard< threading_model > set_attributes_lock; // Lock requirement for the set_attributes method. // construct/copy/destruct basic_logger(); basic_logger(basic_logger const &); template<typename ArgsT> explicit basic_logger(ArgsT const &); basic_logger& operator=(basic_logger const &); // protected member functions shared_ptr< core_type > const & core() const; attribute_set_type & attributes(); attribute_set_type 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< typename attribute_set_type::iterator, bool > add_attribute_unlocked(string_type const &, shared_ptr< attribute > const &); void remove_attribute_unlocked(typename attribute_set_type::iterator); void remove_all_attributes_unlocked(); record_type open_record_unlocked(); template<typename ArgsT> record_type open_record_unlocked(ArgsT const &); void push_record_unlocked(record_type const &); attribute_set_type get_attributes_unlocked() const; void set_attributes_unlocked(attribute_set_type 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: |
|
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 &);Assignment (should be implemented through copy and swap in the final class)
basic_logger
protected member functionsshared_ptr< core_type > const & core() const;
An accessor to the logging system pointer
attribute_set_type & attributes();
An accessor to the logger attributes
attribute_set_type 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< typename attribute_set_type::iterator, bool > add_attribute_unlocked(string_type const & name, shared_ptr< attribute > const & attr);
Unlocked add_attribute
void remove_attribute_unlocked(typename attribute_set_type::iterator it);
Unlocked remove_attribute
void remove_all_attributes_unlocked();
Unlocked remove_all_attributes
record_type open_record_unlocked();
Unlocked open_record
template<typename ArgsT> record_type open_record_unlocked(ArgsT const & args);
Unlocked open_record
void push_record_unlocked(record_type const & record);
Unlocked push_record
attribute_set_type get_attributes_unlocked() const;
Unlocked get_attributes
void set_attributes_unlocked(attribute_set_type const & attrs);
Unlocked set_attributes