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_type > | insertion_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_composer & | operator= (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... | |
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:
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. 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.
typedef CharT boost::sinks::event_log::basic_event_composer< CharT >::char_type |
Character type.
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.
typedef basic_formatter< char_type > boost::sinks::event_log::basic_event_composer< CharT >::formatter_type |
Type of an insertion composer (a formatter)
typedef std::vector< string_type > boost::sinks::event_log::basic_event_composer< CharT >::insertion_list |
Type of the composed insertions list.
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.
|
explicit |
Default constructor.
Creates an empty map of events.
id_mapper | An event identifier mapping function that will be used to extract event ID from attribute values |
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.
boost::sinks::event_log::basic_event_composer< CharT >::~basic_event_composer | ( | ) |
Destructor.
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.
rec | Log record view |
insertions | A sequence of formatted insertion strings |
attributes
basic_event_composer& boost::sinks::event_log::basic_event_composer< CharT >::operator= | ( | basic_event_composer< CharT > | that | ) |
Assignment.
Provides strong exception guarantee.
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.
id | Event identifier. |
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.
id | Event identifier. |
void boost::sinks::event_log::basic_event_composer< CharT >::swap | ( | basic_event_composer< CharT > & | that | ) |
Swaps *this
and that
objects.