Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::sinks::event_log::basic_event_composer< CharT > Class Template Reference

An event composer. More...

#include <event_log_backend.hpp>

Public Types

typedef CharT char_type
 Character type. More...
 
typedef std::basic_string
< char_type
string_type
 String type to be used as a message text holder. More...
 
typedef
boost::log::aux::light_function
< event_id(record_view const &) > 
event_id_mapper_type
 Event identifier mapper type. More...
 
typedef basic_formatter
< char_type
formatter_type
 Type of an insertion composer (a formatter) More...
 
typedef std::vector< string_typeinsertion_list
 Type of the composed insertions list. More...
 

Public Member Functions

 basic_event_composer (event_id_mapper_type const &id_mapper)
 Default constructor. More...
 
 basic_event_composer (basic_event_composer const &that)
 Copy constructor. More...
 
 ~basic_event_composer ()
 Destructor. More...
 
basic_event_composeroperator= (basic_event_composer that)
 Assignment. More...
 
void swap (basic_event_composer &that)
 Swaps *this and that objects. More...
 
event_map_reference operator[] (event_id id)
 Initiates creation of a new event description. More...
 
event_map_reference operator[] (int id)
 Initiates creation of a new event description. More...
 
event_id operator() (record_view const &rec, insertion_list &insertions) const
 Event composition operator. More...
 

Detailed Description

template<typename CharT>
class boost::sinks::event_log::basic_event_composer< CharT >

An event composer.

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.

Member Typedef Documentation

template<typename CharT>
typedef CharT boost::sinks::event_log::basic_event_composer< CharT >::char_type

Character type.

template<typename CharT>
typedef boost::log::aux::light_function< event_id (record_view const&) > boost::sinks::event_log::basic_event_composer< CharT >::event_id_mapper_type

Event identifier mapper type.

Type of an insertion composer (a formatter)

template<typename CharT>
typedef std::vector< string_type > boost::sinks::event_log::basic_event_composer< CharT >::insertion_list

Type of the composed insertions list.

template<typename CharT>
typedef std::basic_string< char_type > boost::sinks::event_log::basic_event_composer< CharT >::string_type

String type to be used as a message text holder.

Constructor & Destructor Documentation

template<typename CharT>
boost::sinks::event_log::basic_event_composer< CharT >::basic_event_composer ( event_id_mapper_type const &  id_mapper)
explicit

Default constructor.

Creates an empty map of events.

Parameters
id_mapperAn event identifier mapping function that will be used to extract event ID from attribute values
template<typename CharT>
boost::sinks::event_log::basic_event_composer< CharT >::basic_event_composer ( basic_event_composer< CharT > const &  that)

Copy constructor.

Performs a deep copy of the object.

Destructor.

Member Function Documentation

template<typename CharT>
event_id boost::sinks::event_log::basic_event_composer< CharT >::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
recLog record view
insertionsA sequence of formatted insertion strings
Returns
An event identifier that was extracted from attributes
template<typename CharT>
basic_event_composer& boost::sinks::event_log::basic_event_composer< CharT >::operator= ( basic_event_composer< CharT >  that)

Assignment.

Provides strong exception guarantee.

template<typename CharT>
event_map_reference boost::sinks::event_log::basic_event_composer< CharT >::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
idEvent identifier.
template<typename CharT>
event_map_reference boost::sinks::event_log::basic_event_composer< CharT >::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
idEvent identifier.
template<typename CharT>
void boost::sinks::event_log::basic_event_composer< CharT >::swap ( basic_event_composer< CharT > &  that)

Swaps *this and that objects.


The documentation for this class was generated from the following file: