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

An implementation of a simple logging sink backend that emits events into Windows NT event log. More...

#include <event_log_backend.hpp>

Inheritance diagram for boost::sinks::basic_simple_event_log_backend< CharT >:
Collaboration diagram for boost::sinks::basic_simple_event_log_backend< CharT >:

Public Types

typedef base_type::char_type char_type
 Character type. More...
 
typedef base_type::string_type string_type
 String type to be used as a message text holder. More...
 
typedef
boost::log::aux::light_function
< event_log::event_type(record_view
const &) > 
event_type_mapper_type
 Mapper type for the event type. More...
 
typedef
base_type::frontend_requirements 
frontend_requirements
 Frontend requirements. More...
 

Public Member Functions

BOOST_LOG_API basic_simple_event_log_backend ()
 Default constructor. More...
 
BOOST_LOG_API ~basic_simple_event_log_backend ()
 Constructor. More...
 
BOOST_LOG_API void set_event_type_mapper (event_type_mapper_type const &mapper)
 The method installs the function object that maps application severity levels to WinAPI event types. More...
 
BOOST_LOG_API void consume (record_view const &rec, string_type const &formatted_message)
 The method puts the formatted message to the event log. More...
 

Static Public Member Functions

static BOOST_LOG_API string_type get_default_log_name ()
 
static BOOST_LOG_API string_type get_default_source_name ()
 

Detailed Description

template<typename CharT>
class boost::sinks::basic_simple_event_log_backend< CharT >

An implementation of a simple logging sink backend that emits events into Windows NT event log.

The sink uses Windows NT 5 (Windows 2000) and later event log API to emit events to an event log. The sink acts as an event source in terms of the API, it implements all needed resources and source registration in the Windows registry that is needed for the event delivery.

The backend performs message text formatting. The composed text is then passed as the first and only string parameter of the event. The resource embedded into the backend describes the event so that the parameter is inserted into the event description text, thus making it visible in the event log.

The backend allows to customize mapping of application severity levels to the native Windows event types. This allows to write portable code even if OS-specific sinks, such as this one, are used.

Note
Since the backend registers itself into Windows registry as the resource file that contains event description, it is important to keep the library binary in a stable place of the filesystem. Otherwise Windows might not be able to load event resources from the library and display events correctly.
It is known that Windows is not able to find event resources in the application executable, which is linked against the static build of the library. Users are advised to use dynamic builds of the library to solve this problem.

Member Typedef Documentation

Character type.

template<typename CharT >
typedef boost::log::aux::light_function< event_log::event_type (record_view const&) > boost::sinks::basic_simple_event_log_backend< CharT >::event_type_mapper_type

Mapper type for the event type.

String type to be used as a message text holder.

Constructor & Destructor Documentation

template<typename CharT >
BOOST_LOG_API boost::sinks::basic_simple_event_log_backend< CharT >::basic_simple_event_log_backend ( )

Default constructor.

Registers event source with name based on the application executable file name in the Application log. If such a registration is already present, it is not overridden.

template<typename CharT >
BOOST_LOG_API boost::sinks::basic_simple_event_log_backend< CharT >::~basic_simple_event_log_backend ( )

Constructor.

Registers event log source with the specified parameters. The following named parameters are supported:

  • target - Specifies an UNC path to the remote server which log records should be sent to. The local machine will be used to process log records, if not specified.
  • log_name - Specifies the log in which the source should be registered. The result of get_default_log_name is used, if the parameter is not specified.
  • log_source - Specifies the source name. The result of get_default_source_name is used, if the parameter is not specified.
  • registration - Specifies the event source registration mode in the Windows registry. Can have values of the registration_mode enum. Default value: on_demand.
Parameters
argsA set of named parameters.

Destructor. Unregisters event source. The log source description is not removed from the Windows registry.

Member Function Documentation

template<typename CharT >
BOOST_LOG_API void boost::sinks::basic_simple_event_log_backend< CharT >::consume ( record_view const &  rec,
string_type const &  formatted_message 
)

The method puts the formatted message to the event log.

template<typename CharT >
static BOOST_LOG_API string_type boost::sinks::basic_simple_event_log_backend< CharT >::get_default_log_name ( )
static
Returns
Default log name: Application
template<typename CharT >
static BOOST_LOG_API string_type boost::sinks::basic_simple_event_log_backend< CharT >::get_default_source_name ( )
static
Returns
Default log source name that is based on the application executable file name and the sink name
template<typename CharT >
BOOST_LOG_API void boost::sinks::basic_simple_event_log_backend< CharT >::set_event_type_mapper ( event_type_mapper_type const &  mapper)

The method installs the function object that maps application severity levels to WinAPI event types.


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