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. typedef base_type::attribute_set_type attribute_set_type; // Attribute set type. typedef base_type::string_type string_type; // String type. typedef base_type::record_type record_type; // Log record type. // construct/copy/destruct basic_composite_logger(); basic_composite_logger(basic_composite_logger const &); template<typename ArgsT> explicit basic_composite_logger(ArgsT const &); basic_composite_logger& operator=(FinalT const &); // public member functions std::pair< typename attribute_set_type::iterator, bool > add_attribute(string_type const &, shared_ptr< attribute > const &); void remove_attribute(typename attribute_set_type::iterator); void remove_all_attributes(); attribute_set_type get_attributes() const; void set_attributes(attribute_set_type const &); record_type open_record(); template<typename ArgsT> record_type open_record(ArgsT const &); void push_record(record_type const &); void swap(basic_composite_logger &); };
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 a MPL type sequence, where each element is an 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
template<typename ArgsT> explicit basic_composite_logger(ArgsT const & args);
Constructor with named parameters
basic_composite_logger& operator=(FinalT const & that);
Assignment for the final class. Threadsafe, provides strong exception guarantee.
basic_composite_logger
public member functionsstd::pair< typename attribute_set_type::iterator, bool > add_attribute(string_type const & name, shared_ptr< 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(typename attribute_set_type::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_type 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_type 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_type 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_type 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_type const & record);
The method pushes the constructed message to the logging core
Parameters: |
|
void swap(basic_composite_logger & that);
Thread-safe implementation of swap