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_event_composer

boost::log::sinks::event_log::basic_event_composer — An event composer.

Synopsis

// In header: <boost/log/sinks/event_log_backend.hpp>

template<typename CharT> 
class basic_event_composer {
public:
  // types
  typedef CharT                          char_type;             // Character type. 
  typedef std::basic_string< char_type > string_type;           // String type to be used as a message text holder. 
  typedef unspecified                    event_id_mapper_type;  // Event identifier mapper type. 
  typedef basic_formatter< char_type >   formatter_type;        // Type of an insertion composer (a formatter) 
  typedef std::vector< string_type >     insertion_list;        // Type of the composed insertions list. 

  // construct/copy/destruct
  explicit basic_event_composer(event_id_mapper_type const &);
  basic_event_composer(basic_event_composer const &);
  basic_event_composer & operator=(basic_event_composer);
  ~basic_event_composer();

  // public member functions
  void swap(basic_event_composer &);
  event_map_reference operator[](event_id);
  event_map_reference operator[](int);
  event_id operator()(record_view const &, insertion_list &) const;
};

Description

This class is a function object that extracts event identifier from the attribute values set and formats insertion strings for the particular event. Each insertion string is formatted with a distinct formatter, which can be created just like regular sinks formatters.

Before using, the composer must be initialized with the following information:

  • Event identifier extraction logic. One can use basic_direct_event_id_mapping or basic_custom_event_id_mapping classes in order to create such extractor and pass it to the composer constructor.

  • Event identifiers and insertion string formatters. The composer provides the following syntax to provide this information:

event_composer comp;
comp[MY_EVENT_ID1] % formatter1 % ... % formatterN;
comp[MY_EVENT_ID2] % formatter1 % ... % formatterN;
...

The event identifiers in square brackets are provided by the message compiler generated header (the actual names are specified in the .mc file). The formatters represent the insertion strings that will be used to replace placeholders in event messages, thus the number and the order of the formatters must correspond to the message definition.

basic_event_composer public construct/copy/destruct

  1. explicit basic_event_composer(event_id_mapper_type const & id_mapper);

    Default constructor. Creates an empty map of events.

    Parameters:

    id_mapper

    An event identifier mapping function that will be used to extract event ID from attribute values

  2. basic_event_composer(basic_event_composer const & that);

    Copy constructor. Performs a deep copy of the object.

  3. basic_event_composer & operator=(basic_event_composer that);

    Assignment. Provides strong exception guarantee.

  4. ~basic_event_composer();

    Destructor

basic_event_composer public member functions

  1. void swap(basic_event_composer & that);

    Swaps *this and that objects.

  2. event_map_reference operator[](event_id id);

    Initiates creation of a new event description. The result of the operator can be used to add formatters for insertion strings construction. The returned reference type is implementation detail.

    Parameters:

    id

    Event identifier.

  3. event_map_reference operator[](int id);

    Initiates creation of a new event description. The result of the operator can be used to add formatters for insertion strings construction. The returned reference type is implementation detail.

    Parameters:

    id

    Event identifier.

  4. event_id operator()(record_view const & rec, insertion_list & insertions) const;

    Event composition operator. Extracts an event identifier from the attribute values by calling event ID mapper. Then runs all formatters that were registered for the event with the extracted ID. The results of formatting are returned in the insertions parameter.

    Parameters:

    insertions

    A sequence of formatted insertion strings

    rec

    Log record view

    Returns:

    An event identifier that was extracted from attributes


PrevUpHomeNext