Chris@16: /* Chris@101: * Copyright Andrey Semashev 2007 - 2015. Chris@16: * Distributed under the Boost Software License, Version 1.0. Chris@16: * (See accompanying file LICENSE_1_0.txt or copy at Chris@16: * http://www.boost.org/LICENSE_1_0.txt) Chris@16: */ Chris@16: /*! Chris@16: * \file event_log_backend.hpp Chris@16: * \author Andrey Semashev Chris@16: * \date 07.11.2008 Chris@16: * Chris@16: * The header contains a logging sink backend that uses Windows NT event log API Chris@16: * for signaling application events. Chris@16: */ Chris@16: Chris@16: #ifndef BOOST_LOG_SINKS_EVENT_LOG_BACKEND_HPP_INCLUDED_ Chris@16: #define BOOST_LOG_SINKS_EVENT_LOG_BACKEND_HPP_INCLUDED_ Chris@16: Chris@16: #include Chris@16: Chris@16: #ifdef BOOST_HAS_PRAGMA_ONCE Chris@16: #pragma once Chris@16: #endif Chris@16: Chris@16: #ifndef BOOST_LOG_WITHOUT_EVENT_LOG Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: Chris@16: BOOST_LOG_OPEN_NAMESPACE Chris@16: Chris@16: namespace sinks { Chris@16: Chris@16: namespace event_log { Chris@16: Chris@16: //! Event log source registration modes Chris@16: enum registration_mode Chris@16: { Chris@16: never, //!< Never register event source, even if it's not registered Chris@16: on_demand, //!< Register if the source is not registered yet Chris@16: forced //!< Register always, event if the source is already registered Chris@16: }; Chris@16: Chris@16: /*! Chris@16: * \brief Straightforward event type mapping Chris@16: * Chris@16: * This type of mapping assumes that attribute with a particular name always Chris@16: * provides values that map directly onto the native event types. The mapping Chris@16: * simply returns the extracted attribute value converted to the native event type. Chris@16: */ Chris@16: template< typename AttributeValueT = int > Chris@16: class direct_event_type_mapping : Chris@16: public basic_direct_mapping< event_type, AttributeValueT > Chris@16: { Chris@16: //! Base type Chris@16: typedef basic_direct_mapping< event_type, AttributeValueT > base_type; Chris@16: Chris@16: public: Chris@16: /*! Chris@16: * Constructor Chris@16: * Chris@16: * \param name Attribute name Chris@16: */ Chris@16: explicit direct_event_type_mapping(attribute_name const& name) : Chris@16: base_type(name, info) Chris@16: { Chris@16: } Chris@16: }; Chris@16: Chris@16: /*! Chris@16: * \brief Customizable event type mapping Chris@16: * Chris@16: * The class allows to setup a custom mapping between an attribute and native event types. Chris@16: * The mapping should be initialized similarly to the standard \c map container, by using Chris@16: * indexing operator and assignment. Chris@16: */ Chris@16: template< typename AttributeValueT = int > Chris@16: class custom_event_type_mapping : Chris@16: public basic_custom_mapping< event_type, AttributeValueT > Chris@16: { Chris@16: //! Base type Chris@16: typedef basic_custom_mapping< event_type, AttributeValueT > base_type; Chris@16: Chris@16: public: Chris@16: /*! Chris@16: * Constructor Chris@16: * Chris@16: * \param name Attribute name Chris@16: */ Chris@16: explicit custom_event_type_mapping(attribute_name const& name) : Chris@16: base_type(name, info) Chris@16: { Chris@16: } Chris@16: }; Chris@16: Chris@16: /*! Chris@16: * \brief Straightforward event ID mapping Chris@16: * Chris@16: * This type of mapping assumes that attribute with a particular name always Chris@16: * provides values that map directly onto the event identifiers. The mapping Chris@16: * simply returns the extracted attribute value converted to the event ID. Chris@16: */ Chris@16: template< typename AttributeValueT = int > Chris@16: class direct_event_id_mapping : Chris@16: public basic_direct_mapping< event_id, AttributeValueT > Chris@16: { Chris@16: //! Base type Chris@16: typedef basic_direct_mapping< event_id, AttributeValueT > base_type; Chris@16: Chris@16: public: Chris@16: /*! Chris@16: * Constructor Chris@16: * Chris@16: * \param name Attribute name Chris@16: */ Chris@16: explicit direct_event_id_mapping(attribute_name const& name) : Chris@16: base_type(name, make_event_id(0)) Chris@16: { Chris@16: } Chris@16: }; Chris@16: Chris@16: /*! Chris@16: * \brief Customizable event ID mapping Chris@16: * Chris@16: * The class allows to setup a custom mapping between an attribute and event identifiers. Chris@16: * The mapping should be initialized similarly to the standard \c map container, by using Chris@16: * indexing operator and assignment. Chris@16: */ Chris@16: template< typename AttributeValueT = int > Chris@16: class custom_event_id_mapping : Chris@16: public basic_custom_mapping< event_id, AttributeValueT > Chris@16: { Chris@16: //! Base type Chris@16: typedef basic_custom_mapping< event_id, AttributeValueT > base_type; Chris@16: Chris@16: public: Chris@16: /*! Chris@16: * Constructor Chris@16: * Chris@16: * \param name Attribute name Chris@16: */ Chris@16: explicit custom_event_id_mapping(attribute_name const& name) : Chris@16: base_type(name, make_event_id(0)) Chris@16: { Chris@16: } Chris@16: }; Chris@16: Chris@16: /*! Chris@16: * \brief Straightforward event category mapping Chris@16: * Chris@16: * This type of mapping assumes that attribute with a particular name always Chris@16: * provides values that map directly onto the event categories. The mapping Chris@16: * simply returns the extracted attribute value converted to the event category. Chris@16: */ Chris@16: template< typename AttributeValueT = int > Chris@16: class direct_event_category_mapping : Chris@16: public basic_direct_mapping< event_category, AttributeValueT > Chris@16: { Chris@16: //! Base type Chris@16: typedef basic_direct_mapping< event_category, AttributeValueT > base_type; Chris@16: Chris@16: public: Chris@16: /*! Chris@16: * Constructor Chris@16: * Chris@16: * \param name Attribute name Chris@16: */ Chris@16: explicit direct_event_category_mapping(attribute_name const& name) : Chris@16: base_type(name, make_event_category(0)) Chris@16: { Chris@16: } Chris@16: }; Chris@16: Chris@16: /*! Chris@16: * \brief Customizable event category mapping Chris@16: * Chris@16: * The class allows to setup a custom mapping between an attribute and event categories. Chris@16: * The mapping should be initialized similarly to the standard \c map container, by using Chris@16: * indexing operator and assignment. Chris@16: */ Chris@16: template< typename AttributeValueT = int > Chris@16: class custom_event_category_mapping : Chris@16: public basic_custom_mapping< event_category, AttributeValueT > Chris@16: { Chris@16: //! Base type Chris@16: typedef basic_custom_mapping< event_category, AttributeValueT > base_type; Chris@16: Chris@16: public: Chris@16: /*! Chris@16: * Constructor Chris@16: * Chris@16: * \param name Attribute name Chris@16: */ Chris@16: explicit custom_event_category_mapping(attribute_name const& name) : Chris@16: base_type(name, make_event_category(0)) Chris@16: { Chris@16: } Chris@16: }; Chris@16: Chris@16: /*! Chris@16: * \brief An event composer Chris@16: * Chris@16: * This class is a function object that extracts event identifier from the attribute values set Chris@16: * and formats insertion strings for the particular event. Each insertion string is formatted with Chris@16: * a distinct formatter, which can be created just like regular sinks formatters. Chris@16: * Chris@16: * Before using, the composer must be initialized with the following information: Chris@16: * \li Event identifier extraction logic. One can use \c basic_direct_event_id_mapping or Chris@16: * \c basic_custom_event_id_mapping classes in order to create such extractor and pass it Chris@16: * to the composer constructor. Chris@16: * \li Event identifiers and insertion string formatters. The composer provides the following Chris@16: * syntax to provide this information: Chris@16: * Chris@16: * \code Chris@16: * event_composer comp; Chris@16: * comp[MY_EVENT_ID1] % formatter1 % ... % formatterN; Chris@16: * comp[MY_EVENT_ID2] % formatter1 % ... % formatterN; Chris@16: * ... Chris@16: * \endcode Chris@16: * Chris@16: * The event identifiers in square brackets are provided by the message compiler generated Chris@16: * header (the actual names are specified in the .mc file). The formatters represent Chris@16: * the insertion strings that will be used to replace placeholders in event messages, Chris@16: * thus the number and the order of the formatters must correspond to the message definition. Chris@16: */ Chris@16: template< typename CharT > Chris@16: class BOOST_LOG_API basic_event_composer Chris@16: { Chris@16: public: Chris@16: //! Character type Chris@16: typedef CharT char_type; Chris@16: //! String type to be used as a message text holder Chris@16: typedef std::basic_string< char_type > string_type; Chris@16: Chris@16: //! Event identifier mapper type Chris@16: typedef boost::log::aux::light_function< event_id (record_view const&) > event_id_mapper_type; Chris@16: Chris@16: //! Type of an insertion composer (a formatter) Chris@16: typedef basic_formatter< char_type > formatter_type; Chris@16: //! Type of the composed insertions list Chris@16: typedef std::vector< string_type > insertion_list; Chris@16: Chris@16: private: Chris@16: //! \cond Chris@16: Chris@16: //! The class that implements formatting of insertion strings Chris@16: class insertion_composer; Chris@16: Chris@16: //! Type of the events map Chris@16: typedef std::map< event_id, insertion_composer > event_map; Chris@16: Chris@16: //! A smart reference that puts formatters into the composer Chris@16: class event_map_reference; Chris@16: friend class event_map_reference; Chris@16: class event_map_reference Chris@16: { Chris@16: private: Chris@16: //! Event identifier Chris@16: event_id m_ID; Chris@16: //! A reference to the object that created the reference Chris@16: basic_event_composer< char_type >& m_Owner; Chris@16: //! A hint for the owner to optimize insertion Chris@16: insertion_composer* m_Composer; Chris@16: Chris@16: public: Chris@16: //! Initializing constructor Chris@16: explicit event_map_reference(event_id id, basic_event_composer< char_type >& owner) : Chris@16: m_ID(id), Chris@16: m_Owner(owner), Chris@16: m_Composer(0) Chris@16: { Chris@16: } Chris@16: //! The operator puts the formatter into the composer Chris@16: template< typename FormatterT > Chris@16: event_map_reference& operator% (FormatterT const& fmt) Chris@16: { Chris@16: m_Composer = m_Owner.add_formatter(m_ID, m_Composer, formatter_type(fmt)); Chris@16: return *this; Chris@16: } Chris@16: }; Chris@16: Chris@16: //! \endcond Chris@16: Chris@16: private: Chris@16: //! The mapper that will extract the event identifier Chris@16: event_id_mapper_type m_EventIDMapper; Chris@16: //! The map of event identifiers and their insertion composers Chris@16: event_map m_EventMap; Chris@16: Chris@16: public: Chris@16: /*! Chris@16: * Default constructor. Creates an empty map of events. Chris@16: * Chris@16: * \param id_mapper An event identifier mapping function that will be used to extract event ID from attribute values Chris@16: */ Chris@16: explicit basic_event_composer(event_id_mapper_type const& id_mapper); Chris@16: /*! Chris@16: * Copy constructor. Performs a deep copy of the object. Chris@16: */ Chris@16: basic_event_composer(basic_event_composer const& that); Chris@16: /*! Chris@16: * Destructor Chris@16: */ Chris@16: ~basic_event_composer(); Chris@16: Chris@16: /*! Chris@16: * Assignment. Provides strong exception guarantee. Chris@16: */ Chris@16: basic_event_composer& operator= (basic_event_composer that); Chris@16: /*! Chris@16: * Swaps \c *this and \c that objects. Chris@16: */ Chris@16: void swap(basic_event_composer& that); Chris@16: /*! Chris@16: * Initiates creation of a new event description. The result of the operator can be used to Chris@16: * add formatters for insertion strings construction. The returned reference type is implementation detail. Chris@16: * Chris@16: * \param id Event identifier. Chris@16: */ Chris@16: event_map_reference operator[] (event_id id); Chris@16: /*! Chris@16: * Initiates creation of a new event description. The result of the operator can be used to Chris@16: * add formatters for insertion strings construction. The returned reference type is implementation detail. Chris@16: * Chris@16: * \param id Event identifier. Chris@16: */ Chris@16: event_map_reference operator[] (int id); Chris@16: /*! Chris@16: * Event composition operator. Extracts an event identifier from the attribute values by calling event ID mapper. Chris@16: * Then runs all formatters that were registered for the event with the extracted ID. The results of formatting Chris@16: * are returned in the \a insertions parameter. Chris@16: * Chris@16: * \param rec Log record view Chris@16: * \param insertions A sequence of formatted insertion strings Chris@16: * \return An event identifier that was extracted from \c attributes Chris@16: */ Chris@16: event_id operator() (record_view const& rec, insertion_list& insertions) const; Chris@16: Chris@16: private: Chris@16: #ifndef BOOST_LOG_DOXYGEN_PASS Chris@16: //! Adds a formatter to the insertion composers list Chris@16: insertion_composer* add_formatter(event_id id, insertion_composer* composer, formatter_type const& fmt); Chris@16: #endif // BOOST_LOG_DOXYGEN_PASS Chris@16: }; Chris@16: Chris@16: #ifdef BOOST_LOG_USE_CHAR Chris@16: typedef basic_event_composer< char > event_composer; //!< Convenience typedef for narrow-character logging Chris@16: #endif Chris@16: #ifdef BOOST_LOG_USE_WCHAR_T Chris@16: typedef basic_event_composer< wchar_t > wevent_composer; //!< Convenience typedef for wide-character logging Chris@16: #endif Chris@16: Chris@16: } // namespace event_log Chris@16: Chris@16: /*! Chris@16: * \brief An implementation of a simple logging sink backend that emits events into Windows NT event log Chris@16: * Chris@16: * The sink uses Windows NT 5 (Windows 2000) and later event log API to emit events Chris@16: * to an event log. The sink acts as an event source in terms of the API, it implements all needed resources Chris@16: * and source registration in the Windows registry that is needed for the event delivery. Chris@16: * Chris@16: * The backend performs message text formatting. The composed text is then passed as the first Chris@16: * and only string parameter of the event. The resource embedded into the backend describes the event Chris@16: * so that the parameter is inserted into the event description text, thus making it visible Chris@16: * in the event log. Chris@16: * Chris@16: * The backend allows to customize mapping of application severity levels to the native Windows event types. Chris@16: * This allows to write portable code even if OS-specific sinks, such as this one, are used. Chris@16: * Chris@16: * \note Since the backend registers itself into Windows registry as the resource file that contains Chris@16: * event description, it is important to keep the library binary in a stable place of the filesystem. Chris@16: * Otherwise Windows might not be able to load event resources from the library and display Chris@16: * events correctly. Chris@16: * Chris@16: * \note It is known that Windows is not able to find event resources in the application executable, Chris@16: * which is linked against the static build of the library. Users are advised to use dynamic Chris@16: * builds of the library to solve this problem. Chris@16: */ Chris@16: template< typename CharT > Chris@16: class basic_simple_event_log_backend : Chris@16: public basic_formatted_sink_backend< CharT, concurrent_feeding > Chris@16: { Chris@16: //! Base type Chris@16: typedef basic_formatted_sink_backend< CharT, concurrent_feeding > base_type; Chris@16: //! Implementation type Chris@16: struct implementation; Chris@16: Chris@16: public: Chris@16: //! Character type Chris@16: typedef typename base_type::char_type char_type; Chris@16: //! String type to be used as a message text holder Chris@16: typedef typename base_type::string_type string_type; Chris@16: Chris@16: //! Mapper type for the event type Chris@16: typedef boost::log::aux::light_function< event_log::event_type (record_view const&) > event_type_mapper_type; Chris@16: Chris@16: private: Chris@16: //! Pointer to the backend implementation that hides various types from windows.h Chris@16: implementation* m_pImpl; Chris@16: Chris@16: public: Chris@16: /*! Chris@16: * Default constructor. Registers event source with name based on the application Chris@16: * executable file name in the Application log. If such a registration is already Chris@16: * present, it is not overridden. Chris@16: */ Chris@16: BOOST_LOG_API basic_simple_event_log_backend(); Chris@16: /*! Chris@16: * Constructor. Registers event log source with the specified parameters. Chris@16: * The following named parameters are supported: Chris@16: * Chris@16: * \li \c target - Specifies an UNC path to the remote server which log records should be sent to. Chris@16: * The local machine will be used to process log records, if not specified. Chris@16: * \li \c log_name - Specifies the log in which the source should be registered. Chris@16: * The result of \c get_default_log_name is used, if the parameter is not specified. Chris@16: * \li \c log_source - Specifies the source name. The result of \c get_default_source_name Chris@16: * is used, if the parameter is not specified. Chris@16: * \li \c registration - Specifies the event source registration mode in the Windows registry. Chris@16: * Can have values of the \c registration_mode enum. Default value: \c on_demand. Chris@16: * Chris@16: * \param args A set of named parameters. Chris@16: */ Chris@16: #ifndef BOOST_LOG_DOXYGEN_PASS Chris@16: BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_CALL(basic_simple_event_log_backend, construct) Chris@16: #else Chris@16: template< typename... ArgsT > Chris@16: explicit basic_simple_event_log_backend(ArgsT... const& args); Chris@16: #endif Chris@16: Chris@16: /*! Chris@16: * Destructor. Unregisters event source. The log source description is not removed from the Windows registry. Chris@16: */ Chris@16: BOOST_LOG_API ~basic_simple_event_log_backend(); Chris@16: Chris@16: /*! Chris@16: * The method installs the function object that maps application severity levels to WinAPI event types Chris@16: */ Chris@16: BOOST_LOG_API void set_event_type_mapper(event_type_mapper_type const& mapper); Chris@16: Chris@16: /*! Chris@16: * \returns Default log name: Application Chris@16: */ Chris@16: BOOST_LOG_API static string_type get_default_log_name(); Chris@16: /*! Chris@16: * \returns Default log source name that is based on the application executable file name and the sink name Chris@16: */ Chris@16: BOOST_LOG_API static string_type get_default_source_name(); Chris@16: Chris@16: /*! Chris@16: * The method puts the formatted message to the event log Chris@16: */ Chris@16: BOOST_LOG_API void consume(record_view const& rec, string_type const& formatted_message); Chris@16: Chris@16: private: Chris@16: #ifndef BOOST_LOG_DOXYGEN_PASS Chris@16: //! Constructs backend implementation Chris@16: template< typename ArgsT > Chris@16: void construct(ArgsT const& args) Chris@16: { Chris@16: construct( Chris@16: args[keywords::target | string_type()], Chris@16: args[keywords::log_name || &basic_simple_event_log_backend::get_default_log_name], Chris@16: args[keywords::log_source || &basic_simple_event_log_backend::get_default_source_name], Chris@16: args[keywords::registration | event_log::on_demand]); Chris@16: } Chris@16: BOOST_LOG_API void construct( Chris@16: string_type const& target, Chris@16: string_type const& log_name, Chris@16: string_type const& source_name, Chris@16: event_log::registration_mode reg_mode); Chris@16: #endif // BOOST_LOG_DOXYGEN_PASS Chris@16: }; Chris@16: Chris@16: /*! Chris@16: * \brief An implementation of a logging sink backend that emits events into Windows NT event log Chris@16: * Chris@16: * The sink uses Windows NT 5 (Windows 2000) and later event log API to emit events Chris@16: * to an event log. The sink acts as an event source. Unlike \c basic_simple_event_log_backend, Chris@16: * this sink backend allows users to specify the custom event message file and supports Chris@16: * mapping attribute values onto several insertion strings. Although it requires considerably Chris@16: * more scaffolding than the simple backend, this allows to support localizable event descriptions. Chris@16: * Chris@16: * Besides the file name of the module with event resources, the backend provides the following Chris@16: * customizations: Chris@16: * \li Remote server UNC address, log name and source name. These parameters have similar meaning Chris@16: * to \c basic_simple_event_log_backend. Chris@16: * \li Event type and category mappings. These are function object that allow to map attribute Chris@16: * values to the according event parameters. One can use mappings in the \c event_log namespace. Chris@16: * \li Event composer. This function object extracts event identifier and formats string insertions, Chris@16: * that will be used by the API to compose the final event message text. Chris@16: */ Chris@16: template< typename CharT > Chris@16: class basic_event_log_backend : Chris@16: public basic_sink_backend< synchronized_feeding > Chris@16: { Chris@16: //! Base type Chris@16: typedef basic_sink_backend< synchronized_feeding > base_type; Chris@16: //! Implementation type Chris@16: struct implementation; Chris@16: Chris@16: public: Chris@16: //! Character type Chris@16: typedef CharT char_type; Chris@16: //! String type Chris@16: typedef std::basic_string< char_type > string_type; Chris@16: //! Type of the composed insertions list Chris@16: typedef std::vector< string_type > insertion_list; Chris@16: Chris@16: //! Mapper type for the event type Chris@16: typedef boost::log::aux::light_function< event_log::event_type (record_view const&) > event_type_mapper_type; Chris@16: //! Mapper type for the event category Chris@16: typedef boost::log::aux::light_function< event_log::event_category (record_view const&) > event_category_mapper_type; Chris@16: //! Event composer type Chris@16: typedef boost::log::aux::light_function< event_log::event_id (record_view const&, insertion_list&) > event_composer_type; Chris@16: Chris@16: private: Chris@16: //! Pointer to the backend implementation that hides various types from windows.h Chris@16: implementation* m_pImpl; Chris@16: Chris@16: public: Chris@16: /*! Chris@16: * Constructor. Registers event source with name based on the application Chris@16: * executable file name in the Application log. If such a registration is already Chris@16: * present, it is not overridden. Chris@16: */ Chris@16: template< typename T > Chris@16: explicit basic_event_log_backend(std::basic_string< T > const& message_file_name) Chris@16: { Chris@16: construct(keywords::message_file = message_file_name); Chris@16: } Chris@16: /*! Chris@16: * Constructor. Registers event source with name based on the application Chris@16: * executable file name in the Application log. If such a registration is already Chris@16: * present, it is not overridden. Chris@16: */ Chris@16: explicit basic_event_log_backend(filesystem::path const& message_file_name) Chris@16: { Chris@16: construct(keywords::message_file = message_file_name); Chris@16: } Chris@16: /*! Chris@16: * Constructor. Registers event log source with the specified parameters. Chris@16: * The following named parameters are supported: Chris@16: * Chris@16: * \li \c message_file - Specifies the file name that contains resources that Chris@16: * describe events and categories. Chris@16: * \li \c target - Specifies an UNC path to the remote server to which log records should be sent to. Chris@16: * The local machine will be used to process log records, if not specified. Chris@16: * \li \c log_name - Specifies the log in which the source should be registered. Chris@16: * The result of \c get_default_log_name is used, if the parameter is not specified. Chris@16: * \li \c log_source - Specifies the source name. The result of \c get_default_source_name Chris@16: * is used, if the parameter is not specified. Chris@16: * \li \c registration - Specifies the event source registration mode in the Windows registry. Chris@16: * Can have values of the \c registration_mode enum. Default value: \c on_demand. Chris@16: * Chris@16: * \param args A set of named parameters. Chris@16: */ Chris@16: #ifndef BOOST_LOG_DOXYGEN_PASS Chris@16: BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_CALL(basic_event_log_backend, construct) Chris@16: #else Chris@16: template< typename... ArgsT > Chris@16: explicit basic_event_log_backend(ArgsT... const& args); Chris@16: #endif Chris@16: Chris@16: /*! Chris@16: * Destructor. Unregisters event source. The log source description is not removed from the Windows registry. Chris@16: */ Chris@16: BOOST_LOG_API ~basic_event_log_backend(); Chris@16: Chris@16: /*! Chris@16: * The method creates an event in the event log Chris@16: * Chris@16: * \param rec Log record to consume Chris@16: */ Chris@16: BOOST_LOG_API void consume(record_view const& rec); Chris@16: Chris@16: /*! Chris@16: * The method installs the function object that maps application severity levels to WinAPI event types Chris@16: */ Chris@16: BOOST_LOG_API void set_event_type_mapper(event_type_mapper_type const& mapper); Chris@16: Chris@16: /*! Chris@16: * The method installs the function object that extracts event category from attribute values Chris@16: */ Chris@16: BOOST_LOG_API void set_event_category_mapper(event_category_mapper_type const& mapper); Chris@16: Chris@16: /*! Chris@16: * The method installs the function object that extracts event identifier from the attributes and creates Chris@16: * insertion strings that will replace placeholders in the event message. Chris@16: */ Chris@16: BOOST_LOG_API void set_event_composer(event_composer_type const& composer); Chris@16: Chris@16: /*! Chris@16: * \returns Default log name: Application Chris@16: */ Chris@16: BOOST_LOG_API static string_type get_default_log_name(); Chris@16: /*! Chris@16: * \returns Default log source name that is based on the application executable file name and the sink name Chris@16: */ Chris@16: BOOST_LOG_API static string_type get_default_source_name(); Chris@16: Chris@16: private: Chris@16: #ifndef BOOST_LOG_DOXYGEN_PASS Chris@16: //! Constructs backend implementation Chris@16: template< typename ArgsT > Chris@16: void construct(ArgsT const& args) Chris@16: { Chris@16: construct( Chris@16: filesystem::path(args[keywords::message_file]), Chris@16: args[keywords::target | string_type()], Chris@16: args[keywords::log_name || &basic_event_log_backend::get_default_log_name], Chris@16: args[keywords::log_source || &basic_event_log_backend::get_default_source_name], Chris@16: args[keywords::registration | event_log::on_demand]); Chris@16: } Chris@16: BOOST_LOG_API void construct( Chris@16: filesystem::path const& message_file_name, Chris@16: string_type const& target, Chris@16: string_type const& log_name, Chris@16: string_type const& source_name, Chris@16: event_log::registration_mode reg_mode); Chris@16: #endif // BOOST_LOG_DOXYGEN_PASS Chris@16: }; Chris@16: Chris@16: #ifdef BOOST_LOG_USE_CHAR Chris@16: typedef basic_simple_event_log_backend< char > simple_event_log_backend; //!< Convenience typedef for narrow-character logging Chris@16: typedef basic_event_log_backend< char > event_log_backend; //!< Convenience typedef for narrow-character logging Chris@16: #endif Chris@16: #ifdef BOOST_LOG_USE_WCHAR_T Chris@16: typedef basic_simple_event_log_backend< wchar_t > wsimple_event_log_backend; //!< Convenience typedef for wide-character logging Chris@16: typedef basic_event_log_backend< wchar_t > wevent_log_backend; //!< Convenience typedef for wide-character logging Chris@16: #endif Chris@16: Chris@16: } // namespace sinks Chris@16: Chris@16: BOOST_LOG_CLOSE_NAMESPACE // namespace log Chris@16: Chris@16: } // namespace boost Chris@16: Chris@16: #include Chris@16: Chris@16: #endif // BOOST_LOG_WITHOUT_EVENT_LOG Chris@16: Chris@16: #endif // BOOST_LOG_SINKS_EVENT_LOG_BACKEND_HPP_INCLUDED_