You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

144 lines
5.3 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: pantheios/util/severity/ACE.h
  3. *
  4. * Purpose: Translations from Pantheios stock severity to ACE priority.
  5. *
  6. * Created: 13th November 2007
  7. * Updated: 14th February 2010
  8. *
  9. * Home: http://www.pantheios.org/
  10. *
  11. * Copyright (c) 2007-2010, Matthew Wilson and Synesis Software
  12. * All rights reserved.
  13. *
  14. * Redistribution and use in source and binary forms, with or without
  15. * modification, are permitted provided that the following conditions are
  16. * met:
  17. *
  18. * - Redistributions of source code must retain the above copyright notice,
  19. * this list of conditions and the following disclaimer.
  20. * - Redistributions in binary form must reproduce the above copyright
  21. * notice, this list of conditions and the following disclaimer in the
  22. * documentation and/or other materials provided with the distribution.
  23. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the
  24. * names of any contributors may be used to endorse or promote products
  25. * derived from this software without specific prior written permission.
  26. *
  27. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
  28. * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  29. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  30. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  31. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  32. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  33. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  34. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  35. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  36. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  37. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. * ////////////////////////////////////////////////////////////////////// */
  40. /** \file pantheios/util/severity/ACE.h
  41. *
  42. * [C, C++] Translations from Pantheios stock severity to ACE priority.
  43. */
  44. #ifndef PANTHEIOS_INCL_PANTHEIOS_UTIL_SEVERITY_H_ACE
  45. #define PANTHEIOS_INCL_PANTHEIOS_UTIL_SEVERITY_H_ACE
  46. /* /////////////////////////////////////////////////////////////////////////
  47. * Version information
  48. */
  49. #ifndef PANTHEIOS_DOCUMENTATION_SKIP_SECTION
  50. # define PANTHEIOS_VER_PANTHEIOS_UTIL_SEVERITY_H_ACE_MAJOR 1
  51. # define PANTHEIOS_VER_PANTHEIOS_UTIL_SEVERITY_H_ACE_MINOR 2
  52. # define PANTHEIOS_VER_PANTHEIOS_UTIL_SEVERITY_H_ACE_REVISION 2
  53. # define PANTHEIOS_VER_PANTHEIOS_UTIL_SEVERITY_H_ACE_EDIT 14
  54. #endif /* !PANTHEIOS_DOCUMENTATION_SKIP_SECTION */
  55. /* /////////////////////////////////////////////////////////////////////////
  56. * Includes
  57. */
  58. #ifndef PANTHEIOS_INCL_PANTHEIOS_H_PANTHEIOS
  59. # include <pantheios/pantheios.h>
  60. #endif /* !PANTHEIOS_INCL_PANTHEIOS_H_PANTHEIOS */
  61. #ifndef PANTHEIOS_INCL_PANTHEIOS_QUALITY_H_CONTRACT
  62. # include <pantheios/quality/contract.h>
  63. #endif /* !PANTHEIOS_INCL_PANTHEIOS_QUALITY_H_CONTRACT */
  64. #ifndef PANTHEIOS_INCL_ACE_H_LOG_PRIORITY
  65. # define PANTHEIOS_INCL_ACE_H_LOG_PRIORITY
  66. # include <ace/Log_Priority.h>
  67. #endif /* !PANTHEIOS_INCL_ACE_H_LOG_PRIORITY */
  68. /* /////////////////////////////////////////////////////////////////////////
  69. * Namespace
  70. */
  71. #if !defined(PANTHEIOS_NO_NAMESPACE)
  72. namespace pantheios
  73. {
  74. #endif /* !PANTHEIOS_NO_NAMESPACE */
  75. /* /////////////////////////////////////////////////////////////////////////
  76. * Functions
  77. */
  78. /** Converts a Pantheios severity level to an ACE priority level
  79. *
  80. * \param severity The Pantheios \link pantheios::pan_severity_t severity level\endlink
  81. *
  82. * \return The ACE priority
  83. */
  84. #ifdef __cplusplus
  85. inline
  86. #else /* ? __cplusplus */
  87. static
  88. #endif /* __cplusplus */
  89. ACE_Log_Priority pantheios_severity_to_ACE_priority(int severity)
  90. {
  91. ACE_Log_Priority priority;
  92. PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_PARAMS_API((severity >= 0 && severity < 16), "invalid severity");
  93. switch(severity)
  94. {
  95. case PANTHEIOS_SEV_EMERGENCY: priority = LM_EMERGENCY; break;
  96. case PANTHEIOS_SEV_ALERT: priority = LM_ALERT; break;
  97. case PANTHEIOS_SEV_CRITICAL: priority = LM_CRITICAL; break;
  98. case PANTHEIOS_SEV_ERROR: priority = LM_ERROR; break;
  99. case PANTHEIOS_SEV_WARNING: priority = LM_WARNING; break;
  100. case PANTHEIOS_SEV_NOTICE: priority = LM_NOTICE; break;
  101. case PANTHEIOS_SEV_INFORMATIONAL: priority = LM_INFO; break;
  102. default:
  103. case PANTHEIOS_SEV_DEBUG: priority = LM_DEBUG; break;
  104. }
  105. return priority;
  106. }
  107. /* /////////////////////////////////////////////////////////////////////////
  108. * Namespace
  109. */
  110. #if !defined(PANTHEIOS_NO_NAMESPACE)
  111. } /* namespace pantheios */
  112. #endif /* !PANTHEIOS_NO_NAMESPACE */
  113. /* /////////////////////////////////////////////////////////////////////////
  114. * Inclusion
  115. */
  116. #ifdef STLSOFT_PPF_pragma_once_SUPPORT
  117. # pragma once
  118. #endif /* STLSOFT_PPF_pragma_once_SUPPORT */
  119. /* ////////////////////////////////////////////////////////////////////// */
  120. #endif /* !PANTHEIOS_INCL_PANTHEIOS_UTIL_SEVERITY_H_ACE */
  121. /* ///////////////////////////// end of file //////////////////////////// */