Priority.hh 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Priority.hh
  3. *
  4. * Copyright 2000, LifeLine Networks BV (www.lifeline.nl). All rights reserved.
  5. * Copyright 2000, Bastiaan Bakker. All rights reserved.
  6. *
  7. * See the COPYING file for the terms of usage and distribution.
  8. */
  9. #ifndef _LOG4CPP_PRIORITY_HH
  10. #define _LOG4CPP_PRIORITY_HH
  11. #include <log4cpp/Portability.hh>
  12. #include <string>
  13. #include <stdexcept>
  14. /*
  15. * Optionally work around rudeness in windows.h on Win32.
  16. */
  17. #ifdef ERROR
  18. #ifdef LOG4CPP_FIX_ERROR_COLLISION
  19. namespace log4cpp {
  20. static const int _tmpERRORValue = ERROR;
  21. }
  22. #undef ERROR
  23. static const int ERROR = log4cpp::_tmpERRORValue;
  24. #define ERROR ERROR
  25. #else // LOG4CPP_FIX_ERROR_COLLISION
  26. #error Naming collision for 'ERROR' detected. Please read the FAQ for a \
  27. workaround.
  28. #endif // LOG4CPP_FIX_ERROR_COLLISION
  29. #endif // ERROR
  30. /*
  31. * Other Win32 rudeness in EDK.h
  32. */
  33. #ifdef DEBUG
  34. #ifdef LOG4CPP_FIX_ERROR_COLLISION
  35. #undef DEBUG
  36. #define DEBUG DEBUG
  37. #else // LOG4CPP_FIX_ERROR_COLLISION
  38. #error Naming collision for 'DEBUG' detected. Please read the FAQ for a \
  39. workaround.
  40. #endif // LOG4CPP_FIX_ERROR_COLLISION
  41. #endif // DEBUG
  42. namespace log4cpp {
  43. /**
  44. * The Priority class provides importance levels with which one
  45. * can categorize log messages.
  46. **/
  47. class LOG4CPP_EXPORT Priority {
  48. public:
  49. static const int MESSAGE_SIZE; // = 8;
  50. /**
  51. * Predefined Levels of Priorities. These correspond to the
  52. * priority levels used by syslog(3).
  53. **/
  54. typedef enum {EMERG = 0,
  55. FATAL = 0,
  56. ALERT = 100,
  57. CRIT = 200,
  58. ERROR = 300,
  59. WARN = 400,
  60. NOTICE = 500,
  61. INFO = 600,
  62. DEBUG = 700,
  63. NOTSET = 800
  64. } PriorityLevel;
  65. /**
  66. * The type of Priority Values
  67. **/
  68. typedef int Value;
  69. /**
  70. * Returns the name of the given priority value.
  71. * Currently, if the value is not one of the PriorityLevel values,
  72. * the method returns the name of the largest priority smaller
  73. * the given value.
  74. * @param priority the numeric value of the priority.
  75. * @returns a string representing the name of the priority.
  76. **/
  77. static const std::string& getPriorityName(int priority) LOG4CPP_NOTHROW;
  78. /**
  79. * Returns the value of the given priority name.
  80. * This can be either one of EMERG ... NOTSET or a
  81. * decimal string representation of the value, e.g. '700' for DEBUG.
  82. * @param priorityName the string containing the the of the priority
  83. * @return the value corresponding with the priority name
  84. * @throw std::invalid_argument if the priorityName does not
  85. * correspond with a known Priority name or a number
  86. **/
  87. static Value getPriorityValue(const std::string& priorityName);
  88. };
  89. }
  90. #endif // _LOG4CPP_PRIORITY_HH