event_log_constants.hpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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_constants.hpp
  9. * \author Andrey Semashev
  10. * \date 07.11.2008
  11. *
  12. * The header contains definition of constants related to Windows NT Event Log API.
  13. * The constants can be used in other places without the event log backend.
  14. */
  15. #ifndef BOOST_LOG_SINKS_EVENT_LOG_CONSTANTS_HPP_INCLUDED_
  16. #define BOOST_LOG_SINKS_EVENT_LOG_CONSTANTS_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 <boost/log/detail/tagged_integer.hpp>
  23. #include <boost/log/detail/header.hpp>
  24. namespace boost {
  25. BOOST_LOG_OPEN_NAMESPACE
  26. namespace sinks {
  27. namespace event_log {
  28. struct event_id_tag;
  29. //! A tagged integral type that represents event identifier for the Windows API
  30. typedef boost::log::aux::tagged_integer< unsigned int, event_id_tag > event_id;
  31. /*!
  32. * The function constructs event identifier from an integer
  33. */
  34. inline event_id make_event_id(unsigned int id)
  35. {
  36. event_id iden = { id };
  37. return iden;
  38. }
  39. struct event_category_tag;
  40. //! A tagged integral type that represents event category for the Windows API
  41. typedef boost::log::aux::tagged_integer< unsigned short, event_category_tag > event_category;
  42. /*!
  43. * The function constructs event category from an integer
  44. */
  45. inline event_category make_event_category(unsigned short cat)
  46. {
  47. event_category category = { cat };
  48. return category;
  49. }
  50. //! Windows event types
  51. enum event_type
  52. {
  53. success = 0, //!< Equivalent to EVENTLOG_SUCCESS
  54. info = 4, //!< Equivalent to EVENTLOG_INFORMATION_TYPE
  55. warning = 2, //!< Equivalent to EVENTLOG_WARNING_TYPE
  56. error = 1 //!< Equivalent to EVENTLOG_ERROR_TYPE
  57. };
  58. /*!
  59. * The function constructs log record level from an integer
  60. */
  61. BOOST_LOG_API event_type make_event_type(unsigned short lev);
  62. } // namespace event_log
  63. } // namespace sinks
  64. BOOST_LOG_CLOSE_NAMESPACE // namespace log
  65. } // namespace boost
  66. #include <boost/log/detail/footer.hpp>
  67. #endif // BOOST_LOG_WITHOUT_EVENT_LOG
  68. #endif // BOOST_LOG_SINKS_EVENT_LOG_CONSTANTS_HPP_INCLUDED_