logger_level.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. #ifndef __LOGGER_LEVEL_H
  15. #define __LOGGER_LEVEL_H
  16. #include <string>
  17. namespace isc {
  18. namespace log {
  19. /// \brief Severity Levels
  20. ///
  21. /// Defines the severity levels for logging. This is shared between the logger
  22. /// and the implementations classes.
  23. ///
  24. /// N.B. The order of the levels - DEBUG less than INFO less that WARN etc. is
  25. /// implicitly assumed in several implementations. They must not be changed.
  26. typedef enum {
  27. DEFAULT = 0, // Default to logging level of the parent
  28. DEBUG = 1,
  29. INFO = 2,
  30. WARN = 3,
  31. ERROR = 4,
  32. FATAL = 5,
  33. NONE = 6 // Disable logging
  34. } Severity;
  35. /// Minimum/maximum debug levels.
  36. const int MIN_DEBUG_LEVEL = 0;
  37. const int MAX_DEBUG_LEVEL = 99;
  38. /// \brief Log level structure
  39. ///
  40. /// A simple pair structure that provides suitable names for the members. It
  41. /// holds a combination of logging severity and debug level.
  42. struct Level {
  43. Severity severity; ///< Logging severity
  44. int dbglevel; ///< Debug level
  45. Level(Severity sev = DEFAULT, int dbg = MIN_DEBUG_LEVEL) :
  46. severity(sev), dbglevel(dbg)
  47. {}
  48. // Default assignment and copy constructor is appropriate
  49. };
  50. /// \brief Returns the isc::log::Severity value represented by the
  51. /// given string
  52. ///
  53. /// If the string is not recognized, returns isc::log::DEBUG.
  54. /// This must be one of the strings "DEBUG", "INFO", "WARN", "ERROR",
  55. /// "FATAL". (Must be upper case and must not contain leading or
  56. /// trailing spaces.)
  57. ///
  58. /// \param sev_str The string representing severity value
  59. /// \return The severity
  60. isc::log::Severity getSeverity(const std::string& sev_str);
  61. } // namespace log
  62. } // namespace isc
  63. #endif // __LOGGER_LEVEL_H