event_log_backend.hpp 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. /*
  2. * Copyright Andrey Semashev 2007 - 2015.
  3. * Distributed under the Boost Software License, Version 1.0.
  4. * (See accompanying file LICENSE_1_0.txt or copy at
  5. * http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. /*!
  8. * \file event_log_backend.hpp
  9. * \author Andrey Semashev
  10. * \date 07.11.2008
  11. *
  12. * The header contains a logging sink backend that uses Windows NT event log API
  13. * for signaling application events.
  14. */
  15. #ifndef BOOST_LOG_SINKS_EVENT_LOG_BACKEND_HPP_INCLUDED_
  16. #define BOOST_LOG_SINKS_EVENT_LOG_BACKEND_HPP_INCLUDED_
  17. #include <boost/log/detail/config.hpp>
  18. #ifdef BOOST_HAS_PRAGMA_ONCE
  19. #pragma once
  20. #endif
  21. #ifndef BOOST_LOG_WITHOUT_EVENT_LOG
  22. #include <map>
  23. #include <vector>
  24. #include <string>
  25. #include <iosfwd>
  26. #include <boost/filesystem/path.hpp>
  27. #include <boost/log/detail/light_function.hpp>
  28. #include <boost/log/detail/parameter_tools.hpp>
  29. #include <boost/log/attributes/attribute_value_set.hpp>
  30. #include <boost/log/keywords/message_file.hpp>
  31. #include <boost/log/keywords/log_name.hpp>
  32. #include <boost/log/keywords/log_source.hpp>
  33. #include <boost/log/keywords/registration.hpp>
  34. #include <boost/log/keywords/target.hpp>
  35. #include <boost/log/sinks/basic_sink_backend.hpp>
  36. #include <boost/log/sinks/frontend_requirements.hpp>
  37. #include <boost/log/sinks/attribute_mapping.hpp>
  38. #include <boost/log/sinks/event_log_constants.hpp>
  39. #include <boost/log/core/record_view.hpp>
  40. #include <boost/log/expressions/formatter.hpp>
  41. #include <boost/log/detail/header.hpp>
  42. namespace boost {
  43. BOOST_LOG_OPEN_NAMESPACE
  44. namespace sinks {
  45. namespace event_log {
  46. //! Event log source registration modes
  47. enum registration_mode
  48. {
  49. never, //!< Never register event source, even if it's not registered
  50. on_demand, //!< Register if the source is not registered yet
  51. forced //!< Register always, event if the source is already registered
  52. };
  53. /*!
  54. * \brief Straightforward event type mapping
  55. *
  56. * This type of mapping assumes that attribute with a particular name always
  57. * provides values that map directly onto the native event types. The mapping
  58. * simply returns the extracted attribute value converted to the native event type.
  59. */
  60. template< typename AttributeValueT = int >
  61. class direct_event_type_mapping :
  62. public basic_direct_mapping< event_type, AttributeValueT >
  63. {
  64. //! Base type
  65. typedef basic_direct_mapping< event_type, AttributeValueT > base_type;
  66. public:
  67. /*!
  68. * Constructor
  69. *
  70. * \param name Attribute name
  71. */
  72. explicit direct_event_type_mapping(attribute_name const& name) :
  73. base_type(name, info)
  74. {
  75. }
  76. };
  77. /*!
  78. * \brief Customizable event type mapping
  79. *
  80. * The class allows to setup a custom mapping between an attribute and native event types.
  81. * The mapping should be initialized similarly to the standard \c map container, by using
  82. * indexing operator and assignment.
  83. */
  84. template< typename AttributeValueT = int >
  85. class custom_event_type_mapping :
  86. public basic_custom_mapping< event_type, AttributeValueT >
  87. {
  88. //! Base type
  89. typedef basic_custom_mapping< event_type, AttributeValueT > base_type;
  90. public:
  91. /*!
  92. * Constructor
  93. *
  94. * \param name Attribute name
  95. */
  96. explicit custom_event_type_mapping(attribute_name const& name) :
  97. base_type(name, info)
  98. {
  99. }
  100. };
  101. /*!
  102. * \brief Straightforward event ID mapping
  103. *
  104. * This type of mapping assumes that attribute with a particular name always
  105. * provides values that map directly onto the event identifiers. The mapping
  106. * simply returns the extracted attribute value converted to the event ID.
  107. */
  108. template< typename AttributeValueT = int >
  109. class direct_event_id_mapping :
  110. public basic_direct_mapping< event_id, AttributeValueT >
  111. {
  112. //! Base type
  113. typedef basic_direct_mapping< event_id, AttributeValueT > base_type;
  114. public:
  115. /*!
  116. * Constructor
  117. *
  118. * \param name Attribute name
  119. */
  120. explicit direct_event_id_mapping(attribute_name const& name) :
  121. base_type(name, make_event_id(0))
  122. {
  123. }
  124. };
  125. /*!
  126. * \brief Customizable event ID mapping
  127. *
  128. * The class allows to setup a custom mapping between an attribute and event identifiers.
  129. * The mapping should be initialized similarly to the standard \c map container, by using
  130. * indexing operator and assignment.
  131. */
  132. template< typename AttributeValueT = int >
  133. class custom_event_id_mapping :
  134. public basic_custom_mapping< event_id, AttributeValueT >
  135. {
  136. //! Base type
  137. typedef basic_custom_mapping< event_id, AttributeValueT > base_type;
  138. public:
  139. /*!
  140. * Constructor
  141. *
  142. * \param name Attribute name
  143. */
  144. explicit custom_event_id_mapping(attribute_name const& name) :
  145. base_type(name, make_event_id(0))
  146. {
  147. }
  148. };
  149. /*!
  150. * \brief Straightforward event category mapping
  151. *
  152. * This type of mapping assumes that attribute with a particular name always
  153. * provides values that map directly onto the event categories. The mapping
  154. * simply returns the extracted attribute value converted to the event category.
  155. */
  156. template< typename AttributeValueT = int >
  157. class direct_event_category_mapping :
  158. public basic_direct_mapping< event_category, AttributeValueT >
  159. {
  160. //! Base type
  161. typedef basic_direct_mapping< event_category, AttributeValueT > base_type;
  162. public:
  163. /*!
  164. * Constructor
  165. *
  166. * \param name Attribute name
  167. */
  168. explicit direct_event_category_mapping(attribute_name const& name) :
  169. base_type(name, make_event_category(0))
  170. {
  171. }
  172. };
  173. /*!
  174. * \brief Customizable event category mapping
  175. *
  176. * The class allows to setup a custom mapping between an attribute and event categories.
  177. * The mapping should be initialized similarly to the standard \c map container, by using
  178. * indexing operator and assignment.
  179. */
  180. template< typename AttributeValueT = int >
  181. class custom_event_category_mapping :
  182. public basic_custom_mapping< event_category, AttributeValueT >
  183. {
  184. //! Base type
  185. typedef basic_custom_mapping< event_category, AttributeValueT > base_type;
  186. public:
  187. /*!
  188. * Constructor
  189. *
  190. * \param name Attribute name
  191. */
  192. explicit custom_event_category_mapping(attribute_name const& name) :
  193. base_type(name, make_event_category(0))
  194. {
  195. }
  196. };
  197. /*!
  198. * \brief An event composer
  199. *
  200. * This class is a function object that extracts event identifier from the attribute values set
  201. * and formats insertion strings for the particular event. Each insertion string is formatted with
  202. * a distinct formatter, which can be created just like regular sinks formatters.
  203. *
  204. * Before using, the composer must be initialized with the following information:
  205. * \li Event identifier extraction logic. One can use \c basic_direct_event_id_mapping or
  206. * \c basic_custom_event_id_mapping classes in order to create such extractor and pass it
  207. * to the composer constructor.
  208. * \li Event identifiers and insertion string formatters. The composer provides the following
  209. * syntax to provide this information:
  210. *
  211. * \code
  212. * event_composer comp;
  213. * comp[MY_EVENT_ID1] % formatter1 % ... % formatterN;
  214. * comp[MY_EVENT_ID2] % formatter1 % ... % formatterN;
  215. * ...
  216. * \endcode
  217. *
  218. * The event identifiers in square brackets are provided by the message compiler generated
  219. * header (the actual names are specified in the .mc file). The formatters represent
  220. * the insertion strings that will be used to replace placeholders in event messages,
  221. * thus the number and the order of the formatters must correspond to the message definition.
  222. */
  223. template< typename CharT >
  224. class BOOST_LOG_API basic_event_composer
  225. {
  226. public:
  227. //! Character type
  228. typedef CharT char_type;
  229. //! String type to be used as a message text holder
  230. typedef std::basic_string< char_type > string_type;
  231. //! Event identifier mapper type
  232. typedef boost::log::aux::light_function< event_id (record_view const&) > event_id_mapper_type;
  233. //! Type of an insertion composer (a formatter)
  234. typedef basic_formatter< char_type > formatter_type;
  235. //! Type of the composed insertions list
  236. typedef std::vector< string_type > insertion_list;
  237. private:
  238. //! \cond
  239. //! The class that implements formatting of insertion strings
  240. class insertion_composer;
  241. //! Type of the events map
  242. typedef std::map< event_id, insertion_composer > event_map;
  243. //! A smart reference that puts formatters into the composer
  244. class event_map_reference;
  245. friend class event_map_reference;
  246. class event_map_reference
  247. {
  248. private:
  249. //! Event identifier
  250. event_id m_ID;
  251. //! A reference to the object that created the reference
  252. basic_event_composer< char_type >& m_Owner;
  253. //! A hint for the owner to optimize insertion
  254. insertion_composer* m_Composer;
  255. public:
  256. //! Initializing constructor
  257. explicit event_map_reference(event_id id, basic_event_composer< char_type >& owner) :
  258. m_ID(id),
  259. m_Owner(owner),
  260. m_Composer(0)
  261. {
  262. }
  263. //! The operator puts the formatter into the composer
  264. template< typename FormatterT >
  265. event_map_reference& operator% (FormatterT const& fmt)
  266. {
  267. m_Composer = m_Owner.add_formatter(m_ID, m_Composer, formatter_type(fmt));
  268. return *this;
  269. }
  270. };
  271. //! \endcond
  272. private:
  273. //! The mapper that will extract the event identifier
  274. event_id_mapper_type m_EventIDMapper;
  275. //! The map of event identifiers and their insertion composers
  276. event_map m_EventMap;
  277. public:
  278. /*!
  279. * Default constructor. Creates an empty map of events.
  280. *
  281. * \param id_mapper An event identifier mapping function that will be used to extract event ID from attribute values
  282. */
  283. explicit basic_event_composer(event_id_mapper_type const& id_mapper);
  284. /*!
  285. * Copy constructor. Performs a deep copy of the object.
  286. */
  287. basic_event_composer(basic_event_composer const& that);
  288. /*!
  289. * Destructor
  290. */
  291. ~basic_event_composer();
  292. /*!
  293. * Assignment. Provides strong exception guarantee.
  294. */
  295. basic_event_composer& operator= (basic_event_composer that);
  296. /*!
  297. * Swaps \c *this and \c that objects.
  298. */
  299. void swap(basic_event_composer& that);
  300. /*!
  301. * Initiates creation of a new event description. The result of the operator can be used to
  302. * add formatters for insertion strings construction. The returned reference type is implementation detail.
  303. *
  304. * \param id Event identifier.
  305. */
  306. event_map_reference operator[] (event_id id);
  307. /*!
  308. * Initiates creation of a new event description. The result of the operator can be used to
  309. * add formatters for insertion strings construction. The returned reference type is implementation detail.
  310. *
  311. * \param id Event identifier.
  312. */
  313. event_map_reference operator[] (int id);
  314. /*!
  315. * Event composition operator. Extracts an event identifier from the attribute values by calling event ID mapper.
  316. * Then runs all formatters that were registered for the event with the extracted ID. The results of formatting
  317. * are returned in the \a insertions parameter.
  318. *
  319. * \param rec Log record view
  320. * \param insertions A sequence of formatted insertion strings
  321. * \return An event identifier that was extracted from \c attributes
  322. */
  323. event_id operator() (record_view const& rec, insertion_list& insertions) const;
  324. private:
  325. #ifndef BOOST_LOG_DOXYGEN_PASS
  326. //! Adds a formatter to the insertion composers list
  327. insertion_composer* add_formatter(event_id id, insertion_composer* composer, formatter_type const& fmt);
  328. #endif // BOOST_LOG_DOXYGEN_PASS
  329. };
  330. #ifdef BOOST_LOG_USE_CHAR
  331. typedef basic_event_composer< char > event_composer; //!< Convenience typedef for narrow-character logging
  332. #endif
  333. #ifdef BOOST_LOG_USE_WCHAR_T
  334. typedef basic_event_composer< wchar_t > wevent_composer; //!< Convenience typedef for wide-character logging
  335. #endif
  336. } // namespace event_log
  337. /*!
  338. * \brief An implementation of a simple logging sink backend that emits events into Windows NT event log
  339. *
  340. * The sink uses Windows NT 5 (Windows 2000) and later event log API to emit events
  341. * to an event log. The sink acts as an event source in terms of the API, it implements all needed resources
  342. * and source registration in the Windows registry that is needed for the event delivery.
  343. *
  344. * The backend performs message text formatting. The composed text is then passed as the first
  345. * and only string parameter of the event. The resource embedded into the backend describes the event
  346. * so that the parameter is inserted into the event description text, thus making it visible
  347. * in the event log.
  348. *
  349. * The backend allows to customize mapping of application severity levels to the native Windows event types.
  350. * This allows to write portable code even if OS-specific sinks, such as this one, are used.
  351. *
  352. * \note Since the backend registers itself into Windows registry as the resource file that contains
  353. * event description, it is important to keep the library binary in a stable place of the filesystem.
  354. * Otherwise Windows might not be able to load event resources from the library and display
  355. * events correctly.
  356. *
  357. * \note It is known that Windows is not able to find event resources in the application executable,
  358. * which is linked against the static build of the library. Users are advised to use dynamic
  359. * builds of the library to solve this problem.
  360. */
  361. template< typename CharT >
  362. class basic_simple_event_log_backend :
  363. public basic_formatted_sink_backend< CharT, concurrent_feeding >
  364. {
  365. //! Base type
  366. typedef basic_formatted_sink_backend< CharT, concurrent_feeding > base_type;
  367. //! Implementation type
  368. struct implementation;
  369. public:
  370. //! Character type
  371. typedef typename base_type::char_type char_type;
  372. //! String type to be used as a message text holder
  373. typedef typename base_type::string_type string_type;
  374. //! Mapper type for the event type
  375. typedef boost::log::aux::light_function< event_log::event_type (record_view const&) > event_type_mapper_type;
  376. private:
  377. //! Pointer to the backend implementation that hides various types from windows.h
  378. implementation* m_pImpl;
  379. public:
  380. /*!
  381. * Default constructor. Registers event source with name based on the application
  382. * executable file name in the Application log. If such a registration is already
  383. * present, it is not overridden.
  384. */
  385. BOOST_LOG_API basic_simple_event_log_backend();
  386. /*!
  387. * Constructor. Registers event log source with the specified parameters.
  388. * The following named parameters are supported:
  389. *
  390. * \li \c target - Specifies an UNC path to the remote server which log records should be sent to.
  391. * The local machine will be used to process log records, if not specified.
  392. * \li \c log_name - Specifies the log in which the source should be registered.
  393. * The result of \c get_default_log_name is used, if the parameter is not specified.
  394. * \li \c log_source - Specifies the source name. The result of \c get_default_source_name
  395. * is used, if the parameter is not specified.
  396. * \li \c registration - Specifies the event source registration mode in the Windows registry.
  397. * Can have values of the \c registration_mode enum. Default value: \c on_demand.
  398. *
  399. * \param args A set of named parameters.
  400. */
  401. #ifndef BOOST_LOG_DOXYGEN_PASS
  402. BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_CALL(basic_simple_event_log_backend, construct)
  403. #else
  404. template< typename... ArgsT >
  405. explicit basic_simple_event_log_backend(ArgsT... const& args);
  406. #endif
  407. /*!
  408. * Destructor. Unregisters event source. The log source description is not removed from the Windows registry.
  409. */
  410. BOOST_LOG_API ~basic_simple_event_log_backend();
  411. /*!
  412. * The method installs the function object that maps application severity levels to WinAPI event types
  413. */
  414. BOOST_LOG_API void set_event_type_mapper(event_type_mapper_type const& mapper);
  415. /*!
  416. * \returns Default log name: Application
  417. */
  418. BOOST_LOG_API static string_type get_default_log_name();
  419. /*!
  420. * \returns Default log source name that is based on the application executable file name and the sink name
  421. */
  422. BOOST_LOG_API static string_type get_default_source_name();
  423. /*!
  424. * The method puts the formatted message to the event log
  425. */
  426. BOOST_LOG_API void consume(record_view const& rec, string_type const& formatted_message);
  427. private:
  428. #ifndef BOOST_LOG_DOXYGEN_PASS
  429. //! Constructs backend implementation
  430. template< typename ArgsT >
  431. void construct(ArgsT const& args)
  432. {
  433. construct(
  434. args[keywords::target | string_type()],
  435. args[keywords::log_name || &basic_simple_event_log_backend::get_default_log_name],
  436. args[keywords::log_source || &basic_simple_event_log_backend::get_default_source_name],
  437. args[keywords::registration | event_log::on_demand]);
  438. }
  439. BOOST_LOG_API void construct(
  440. string_type const& target,
  441. string_type const& log_name,
  442. string_type const& source_name,
  443. event_log::registration_mode reg_mode);
  444. #endif // BOOST_LOG_DOXYGEN_PASS
  445. };
  446. /*!
  447. * \brief An implementation of a logging sink backend that emits events into Windows NT event log
  448. *
  449. * The sink uses Windows NT 5 (Windows 2000) and later event log API to emit events
  450. * to an event log. The sink acts as an event source. Unlike \c basic_simple_event_log_backend,
  451. * this sink backend allows users to specify the custom event message file and supports
  452. * mapping attribute values onto several insertion strings. Although it requires considerably
  453. * more scaffolding than the simple backend, this allows to support localizable event descriptions.
  454. *
  455. * Besides the file name of the module with event resources, the backend provides the following
  456. * customizations:
  457. * \li Remote server UNC address, log name and source name. These parameters have similar meaning
  458. * to \c basic_simple_event_log_backend.
  459. * \li Event type and category mappings. These are function object that allow to map attribute
  460. * values to the according event parameters. One can use mappings in the \c event_log namespace.
  461. * \li Event composer. This function object extracts event identifier and formats string insertions,
  462. * that will be used by the API to compose the final event message text.
  463. */
  464. template< typename CharT >
  465. class basic_event_log_backend :
  466. public basic_sink_backend< synchronized_feeding >
  467. {
  468. //! Base type
  469. typedef basic_sink_backend< synchronized_feeding > base_type;
  470. //! Implementation type
  471. struct implementation;
  472. public:
  473. //! Character type
  474. typedef CharT char_type;
  475. //! String type
  476. typedef std::basic_string< char_type > string_type;
  477. //! Type of the composed insertions list
  478. typedef std::vector< string_type > insertion_list;
  479. //! Mapper type for the event type
  480. typedef boost::log::aux::light_function< event_log::event_type (record_view const&) > event_type_mapper_type;
  481. //! Mapper type for the event category
  482. typedef boost::log::aux::light_function< event_log::event_category (record_view const&) > event_category_mapper_type;
  483. //! Event composer type
  484. typedef boost::log::aux::light_function< event_log::event_id (record_view const&, insertion_list&) > event_composer_type;
  485. private:
  486. //! Pointer to the backend implementation that hides various types from windows.h
  487. implementation* m_pImpl;
  488. public:
  489. /*!
  490. * Constructor. Registers event source with name based on the application
  491. * executable file name in the Application log. If such a registration is already
  492. * present, it is not overridden.
  493. */
  494. template< typename T >
  495. explicit basic_event_log_backend(std::basic_string< T > const& message_file_name)
  496. {
  497. construct(keywords::message_file = message_file_name);
  498. }
  499. /*!
  500. * Constructor. Registers event source with name based on the application
  501. * executable file name in the Application log. If such a registration is already
  502. * present, it is not overridden.
  503. */
  504. explicit basic_event_log_backend(filesystem::path const& message_file_name)
  505. {
  506. construct(keywords::message_file = message_file_name);
  507. }
  508. /*!
  509. * Constructor. Registers event log source with the specified parameters.
  510. * The following named parameters are supported:
  511. *
  512. * \li \c message_file - Specifies the file name that contains resources that
  513. * describe events and categories. This parameter is mandatory unless \c registration is \c never.
  514. * \li \c target - Specifies an UNC path to the remote server to which log records should be sent to.
  515. * The local machine will be used to process log records, if not specified.
  516. * \li \c log_name - Specifies the log in which the source should be registered.
  517. * The result of \c get_default_log_name is used, if the parameter is not specified.
  518. * \li \c log_source - Specifies the source name. The result of \c get_default_source_name
  519. * is used, if the parameter is not specified.
  520. * \li \c registration - Specifies the event source registration mode in the Windows registry.
  521. * Can have values of the \c registration_mode enum. Default value: \c on_demand.
  522. *
  523. * \param args A set of named parameters.
  524. */
  525. #ifndef BOOST_LOG_DOXYGEN_PASS
  526. BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_CALL(basic_event_log_backend, construct)
  527. #else
  528. template< typename... ArgsT >
  529. explicit basic_event_log_backend(ArgsT... const& args);
  530. #endif
  531. /*!
  532. * Destructor. Unregisters event source. The log source description is not removed from the Windows registry.
  533. */
  534. BOOST_LOG_API ~basic_event_log_backend();
  535. /*!
  536. * The method creates an event in the event log
  537. *
  538. * \param rec Log record to consume
  539. */
  540. BOOST_LOG_API void consume(record_view const& rec);
  541. /*!
  542. * The method installs the function object that maps application severity levels to WinAPI event types
  543. */
  544. BOOST_LOG_API void set_event_type_mapper(event_type_mapper_type const& mapper);
  545. /*!
  546. * The method installs the function object that extracts event category from attribute values
  547. */
  548. BOOST_LOG_API void set_event_category_mapper(event_category_mapper_type const& mapper);
  549. /*!
  550. * The method installs the function object that extracts event identifier from the attributes and creates
  551. * insertion strings that will replace placeholders in the event message.
  552. */
  553. BOOST_LOG_API void set_event_composer(event_composer_type const& composer);
  554. /*!
  555. * \returns Default log name: Application
  556. */
  557. BOOST_LOG_API static string_type get_default_log_name();
  558. /*!
  559. * \returns Default log source name that is based on the application executable file name and the sink name
  560. */
  561. BOOST_LOG_API static string_type get_default_source_name();
  562. private:
  563. #ifndef BOOST_LOG_DOXYGEN_PASS
  564. //! Constructs backend implementation
  565. template< typename ArgsT >
  566. void construct(ArgsT const& args)
  567. {
  568. construct(
  569. filesystem::path(args[keywords::message_file | filesystem::path()]),
  570. args[keywords::target | string_type()],
  571. args[keywords::log_name || &basic_event_log_backend::get_default_log_name],
  572. args[keywords::log_source || &basic_event_log_backend::get_default_source_name],
  573. args[keywords::registration | event_log::on_demand]);
  574. }
  575. BOOST_LOG_API void construct(
  576. filesystem::path const& message_file_name,
  577. string_type const& target,
  578. string_type const& log_name,
  579. string_type const& source_name,
  580. event_log::registration_mode reg_mode);
  581. #endif // BOOST_LOG_DOXYGEN_PASS
  582. };
  583. #ifdef BOOST_LOG_USE_CHAR
  584. typedef basic_simple_event_log_backend< char > simple_event_log_backend; //!< Convenience typedef for narrow-character logging
  585. typedef basic_event_log_backend< char > event_log_backend; //!< Convenience typedef for narrow-character logging
  586. #endif
  587. #ifdef BOOST_LOG_USE_WCHAR_T
  588. typedef basic_simple_event_log_backend< wchar_t > wsimple_event_log_backend; //!< Convenience typedef for wide-character logging
  589. typedef basic_event_log_backend< wchar_t > wevent_log_backend; //!< Convenience typedef for wide-character logging
  590. #endif
  591. } // namespace sinks
  592. BOOST_LOG_CLOSE_NAMESPACE // namespace log
  593. } // namespace boost
  594. #include <boost/log/detail/footer.hpp>
  595. #endif // BOOST_LOG_WITHOUT_EVENT_LOG
  596. #endif // BOOST_LOG_SINKS_EVENT_LOG_BACKEND_HPP_INCLUDED_