...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_composite_logger — A composite logger that inherits a number of features.
// In header: <boost/log/sources/basic_logger.hpp> template<typename CharT, typename FinalT, typename ThreadingModelT, typename FeaturesT> class basic_composite_logger { public: // types typedef base_type::threading_model threading_model; // Threading model being used. // construct/copy/destruct basic_composite_logger(); basic_composite_logger(basic_composite_logger const &); basic_composite_logger(logger_base &&); template<typename ArgsT> explicit basic_composite_logger(ArgsT const &); // public member functions std::pair< attribute_set::iterator, bool > add_attribute(attribute_name const &, attribute const &); void remove_attribute(attribute_set::iterator); void remove_all_attributes(); attribute_set get_attributes() const; void set_attributes(attribute_set const &); record open_record(); template<typename ArgsT> record open_record(ArgsT const &); void push_record(record &&); void swap(basic_composite_logger &); // protected member functions FinalT & assign(FinalT const &); };
The composite logger is a helper class that simplifies feature composition into the final logger. The user's logger class is expected to derive from the composite logger class, instantiated with the character type, the user's logger class, the threading model and the list of the required features. The former three parameters are passed to the basic_logger
class template. The feature list must be an MPL type sequence, where each element is a unary MPL metafunction class, that upon applying on its argument results in a logging feature class that derives from the argument. Every logger feature provided by the library can participate in the feature list.
basic_composite_logger
public
construct/copy/destructbasic_composite_logger();
Default constructor (default-constructs all features)
basic_composite_logger(basic_composite_logger const & that);
Copy constructor
basic_composite_logger(logger_base && that);
Move constructor
template<typename ArgsT> explicit basic_composite_logger(ArgsT const & args);
Constructor with named parameters
basic_composite_logger
public member functionsstd::pair< attribute_set::iterator, bool > add_attribute(attribute_name const & name, attribute const & attr);
The method adds an attribute to the source-specific attribute set. The attribute will be implicitly added to every log record made with the current logger.
Parameters: |
|
||||
Returns: |
A pair of values. If the second member is |
void remove_attribute(attribute_set::iterator it);
The method removes an attribute from the source-specific attribute set.
Parameters: |
|
||
Requires: |
The attribute was added with the add_attribute call for this instance of the logger. |
||
Postconditions: |
The attribute is no longer registered as a source-specific attribute for this logger. The iterator is invalidated after removal. |
void remove_all_attributes();
The method removes all attributes from the logger. All iterators and references to the removed attributes are invalidated.
attribute_set get_attributes() const;
The method retrieves a copy of a set with all attributes from the logger.
Returns: |
The copy of the attribute set. Attributes are shallow-copied. |
void set_attributes(attribute_set const & attrs);
The method installs the whole attribute set into the logger. All iterators and references to elements of the previous set are invalidated. Iterators to the attrs set are not valid to be used with the logger (that is, the logger owns a copy of attrs after completion).
Parameters: |
|
record open_record();
The method opens a new log record in the logging core.
Returns: |
A valid record handle if the logging record is opened successfully, an invalid handle otherwise. |
template<typename ArgsT> record open_record(ArgsT const & args);
The method opens a new log record in the logging core.
Parameters: |
|
||
Returns: |
A valid record handle if the logging record is opened successfully, an invalid handle otherwise. |
void push_record(record && rec);
The method pushes the constructed message to the logging core
Parameters: |
|
void swap(basic_composite_logger & that);
Thread-safe implementation of swap