absl_log.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. // Copyright 2022 The Abseil Authors.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // https://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. //
  15. // -----------------------------------------------------------------------------
  16. // File: log/absl_log.h
  17. // -----------------------------------------------------------------------------
  18. //
  19. // This header declares a family of `ABSL_LOG` macros as alternative spellings
  20. // for macros in `log.h`.
  21. //
  22. // Basic invocation looks like this:
  23. //
  24. // ABSL_LOG(INFO) << "Found " << num_cookies << " cookies";
  25. //
  26. // Most `ABSL_LOG` macros take a severity level argument. The severity levels
  27. // are `INFO`, `WARNING`, `ERROR`, and `FATAL`.
  28. //
  29. // For full documentation, see comments in `log.h`, which includes full
  30. // reference documentation on use of the equivalent `LOG` macro and has an
  31. // identical set of macros without the ABSL_* prefix.
  32. #ifndef ABSL_LOG_ABSL_LOG_H_
  33. #define ABSL_LOG_ABSL_LOG_H_
  34. #include "absl/log/internal/log_impl.h"
  35. #define ABSL_LOG(severity) ABSL_LOG_INTERNAL_LOG_IMPL(_##severity)
  36. #define ABSL_PLOG(severity) ABSL_LOG_INTERNAL_PLOG_IMPL(_##severity)
  37. #define ABSL_DLOG(severity) ABSL_LOG_INTERNAL_DLOG_IMPL(_##severity)
  38. #define ABSL_VLOG(verbose_level) ABSL_LOG_INTERNAL_VLOG_IMPL(verbose_level)
  39. #define ABSL_DVLOG(verbose_level) ABSL_LOG_INTERNAL_DVLOG_IMPL(verbose_level)
  40. #define ABSL_LOG_IF(severity, condition) \
  41. ABSL_LOG_INTERNAL_LOG_IF_IMPL(_##severity, condition)
  42. #define ABSL_PLOG_IF(severity, condition) \
  43. ABSL_LOG_INTERNAL_PLOG_IF_IMPL(_##severity, condition)
  44. #define ABSL_DLOG_IF(severity, condition) \
  45. ABSL_LOG_INTERNAL_DLOG_IF_IMPL(_##severity, condition)
  46. #define ABSL_LOG_EVERY_N(severity, n) \
  47. ABSL_LOG_INTERNAL_LOG_EVERY_N_IMPL(_##severity, n)
  48. #define ABSL_LOG_FIRST_N(severity, n) \
  49. ABSL_LOG_INTERNAL_LOG_FIRST_N_IMPL(_##severity, n)
  50. #define ABSL_LOG_EVERY_POW_2(severity) \
  51. ABSL_LOG_INTERNAL_LOG_EVERY_POW_2_IMPL(_##severity)
  52. #define ABSL_LOG_EVERY_N_SEC(severity, n_seconds) \
  53. ABSL_LOG_INTERNAL_LOG_EVERY_N_SEC_IMPL(_##severity, n_seconds)
  54. #define ABSL_PLOG_EVERY_N(severity, n) \
  55. ABSL_LOG_INTERNAL_PLOG_EVERY_N_IMPL(_##severity, n)
  56. #define ABSL_PLOG_FIRST_N(severity, n) \
  57. ABSL_LOG_INTERNAL_PLOG_FIRST_N_IMPL(_##severity, n)
  58. #define ABSL_PLOG_EVERY_POW_2(severity) \
  59. ABSL_LOG_INTERNAL_PLOG_EVERY_POW_2_IMPL(_##severity)
  60. #define ABSL_PLOG_EVERY_N_SEC(severity, n_seconds) \
  61. ABSL_LOG_INTERNAL_PLOG_EVERY_N_SEC_IMPL(_##severity, n_seconds)
  62. #define ABSL_DLOG_EVERY_N(severity, n) \
  63. ABSL_LOG_INTERNAL_DLOG_EVERY_N_IMPL(_##severity, n)
  64. #define ABSL_DLOG_FIRST_N(severity, n) \
  65. ABSL_LOG_INTERNAL_DLOG_FIRST_N_IMPL(_##severity, n)
  66. #define ABSL_DLOG_EVERY_POW_2(severity) \
  67. ABSL_LOG_INTERNAL_DLOG_EVERY_POW_2_IMPL(_##severity)
  68. #define ABSL_DLOG_EVERY_N_SEC(severity, n_seconds) \
  69. ABSL_LOG_INTERNAL_DLOG_EVERY_N_SEC_IMPL(_##severity, n_seconds)
  70. #define ABSL_VLOG_EVERY_N(verbose_level, n) \
  71. ABSL_LOG_INTERNAL_VLOG_EVERY_N_IMPL(verbose_level, n)
  72. #define ABSL_VLOG_FIRST_N(verbose_level, n) \
  73. ABSL_LOG_INTERNAL_VLOG_FIRST_N_IMPL(verbose_level, n)
  74. #define ABSL_VLOG_EVERY_POW_2(verbose_level, n) \
  75. ABSL_LOG_INTERNAL_VLOG_EVERY_POW_2_IMPL(verbose_level, n)
  76. #define ABSL_VLOG_EVERY_N_SEC(verbose_level, n) \
  77. ABSL_LOG_INTERNAL_VLOG_EVERY_N_SEC_IMPL(verbose_level, n)
  78. #define ABSL_LOG_IF_EVERY_N(severity, condition, n) \
  79. ABSL_LOG_INTERNAL_LOG_IF_EVERY_N_IMPL(_##severity, condition, n)
  80. #define ABSL_LOG_IF_FIRST_N(severity, condition, n) \
  81. ABSL_LOG_INTERNAL_LOG_IF_FIRST_N_IMPL(_##severity, condition, n)
  82. #define ABSL_LOG_IF_EVERY_POW_2(severity, condition) \
  83. ABSL_LOG_INTERNAL_LOG_IF_EVERY_POW_2_IMPL(_##severity, condition)
  84. #define ABSL_LOG_IF_EVERY_N_SEC(severity, condition, n_seconds) \
  85. ABSL_LOG_INTERNAL_LOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds)
  86. #define ABSL_PLOG_IF_EVERY_N(severity, condition, n) \
  87. ABSL_LOG_INTERNAL_PLOG_IF_EVERY_N_IMPL(_##severity, condition, n)
  88. #define ABSL_PLOG_IF_FIRST_N(severity, condition, n) \
  89. ABSL_LOG_INTERNAL_PLOG_IF_FIRST_N_IMPL(_##severity, condition, n)
  90. #define ABSL_PLOG_IF_EVERY_POW_2(severity, condition) \
  91. ABSL_LOG_INTERNAL_PLOG_IF_EVERY_POW_2_IMPL(_##severity, condition)
  92. #define ABSL_PLOG_IF_EVERY_N_SEC(severity, condition, n_seconds) \
  93. ABSL_LOG_INTERNAL_PLOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds)
  94. #define ABSL_DLOG_IF_EVERY_N(severity, condition, n) \
  95. ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_IMPL(_##severity, condition, n)
  96. #define ABSL_DLOG_IF_FIRST_N(severity, condition, n) \
  97. ABSL_LOG_INTERNAL_DLOG_IF_FIRST_N_IMPL(_##severity, condition, n)
  98. #define ABSL_DLOG_IF_EVERY_POW_2(severity, condition) \
  99. ABSL_LOG_INTERNAL_DLOG_IF_EVERY_POW_2_IMPL(_##severity, condition)
  100. #define ABSL_DLOG_IF_EVERY_N_SEC(severity, condition, n_seconds) \
  101. ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds)
  102. #endif // ABSL_LOG_ABSL_LOG_H_