severity.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Copyright The OpenTelemetry Authors
  2. // SPDX-License-Identifier: Apache-2.0
  3. #pragma once
  4. #include <cstdint>
  5. #include "opentelemetry/nostd/string_view.h"
  6. #include "opentelemetry/version.h"
  7. OPENTELEMETRY_BEGIN_NAMESPACE
  8. namespace logs
  9. {
  10. /**
  11. * Severity Levels assigned to log events, based on Log Data Model,
  12. * with the addition of kInvalid (mapped to a severity number of 0).
  13. *
  14. * See
  15. * https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md#field-severitynumber
  16. */
  17. enum class Severity : uint8_t
  18. {
  19. kInvalid = 0,
  20. kTrace = 1,
  21. kTrace2 = 2,
  22. kTrace3 = 3,
  23. kTrace4 = 4,
  24. kDebug = 5,
  25. kDebug2 = 6,
  26. kDebug3 = 7,
  27. kDebug4 = 8,
  28. kInfo = 9,
  29. kInfo2 = 10,
  30. kInfo3 = 11,
  31. kInfo4 = 12,
  32. kWarn = 13,
  33. kWarn2 = 14,
  34. kWarn3 = 15,
  35. kWarn4 = 16,
  36. kError = 17,
  37. kError2 = 18,
  38. kError3 = 19,
  39. kError4 = 20,
  40. kFatal = 21,
  41. kFatal2 = 22,
  42. kFatal3 = 23,
  43. kFatal4 = 24
  44. };
  45. const uint8_t kMaxSeverity = 255;
  46. /**
  47. * Mapping of the severity enum above, to a severity text string (in all caps).
  48. * This severity text can be printed out by exporters. Capital letters follow the
  49. * spec naming convention.
  50. *
  51. * Included to follow the specification's recommendation to print both
  52. * severity number and text in each log record.
  53. */
  54. const nostd::string_view SeverityNumToText[25] = {
  55. "INVALID", "TRACE", "TRACE2", "TRACE3", "TRACE4", "DEBUG", "DEBUG2", "DEBUG3", "DEBUG4",
  56. "INFO", "INFO2", "INFO3", "INFO4", "WARN", "WARN2", "WARN3", "WARN4", "ERROR",
  57. "ERROR2", "ERROR3", "ERROR4", "FATAL", "FATAL2", "FATAL3", "FATAL4"};
  58. } // namespace logs
  59. OPENTELEMETRY_END_NAMESPACE