Boost C++ Libraries

PrevUpHomeNext

Class template basic_composite_logger

boost::log::sources::basic_composite_logger — A composite logger that inherits a number of features.

Synopsis

// 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 &);
};

Description

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/destruct

  1. basic_composite_logger();

    Default constructor (default-constructs all features)

  2. basic_composite_logger(basic_composite_logger const & that);

    Copy constructor

  3. template<typename ArgsT> explicit basic_composite_logger(ArgsT const & args);

    Constructor with named parameters

  4. basic_composite_logger& operator=(FinalT const & that);

    Assignment for the final class. Threadsafe, provides strong exception guarantee.

basic_composite_logger public member functions

  1. std::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:
    attr

    Pointer to the attribute. Must not be NULL.

    name

    The attribute name.

    Returns:

    A pair of values. If the second member is true, then the attribute is added and the first member points to the attribute. Otherwise the attribute was not added and the first member points to the attribute that prevents addition.

  2. void remove_attribute(typename attribute_set_type::iterator it);

    The method removes an attribute from the source-specific attribute set.

    Parameters:
    it

    Iterator to the previously added attribute.

    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.

  3. void remove_all_attributes();

    The method removes all attributes from the logger. All iterators and references to the removed attributes are invalidated.

  4. 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.

  5. 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:
    attrs

    The set of attributes to install into the logger. Attributes are shallow-copied.

  6. 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.

  7. template<typename ArgsT> record_type open_record(ArgsT const & args);

    The method opens a new log record in the logging core.

    Parameters:
    args

    A set of additional named arguments. The parameter is ignored.

    Returns:

    A valid record handle if the logging record is opened successfully, an invalid handle otherwise.

  8. void push_record(record_type const & record);

    The method pushes the constructed message to the logging core

    Parameters:
    record

    The log record with the formatted message

  9. void swap(basic_composite_logger & that);

    Thread-safe implementation of swap


PrevUpHomeNext