Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
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. 

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

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

  1. basic_composite_logger();

    Default constructor (default-constructs all features)

  2. basic_composite_logger(basic_composite_logger const & that);

    Copy constructor

  3. basic_composite_logger(logger_base && that);

    Move constructor

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

    Constructor with named parameters

basic_composite_logger public member functions

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

    attr

    The attribute factory.

    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(attribute_set::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 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 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 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 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 && rec);

    The method pushes the constructed message to the logging core

    Parameters:

    rec

    The log record with the formatted message

  9. void swap(basic_composite_logger & that);

    Thread-safe implementation of swap

basic_composite_logger protected member functions

  1. FinalT & assign(FinalT const & that);

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


PrevUpHomeNext