absl_log.h 5.3 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 `Y_ABSL_LOG` macros as alternative spellings
  20. // for macros in `log.h`.
  21. //
  22. // Basic invocation looks like this:
  23. //
  24. // Y_ABSL_LOG(INFO) << "Found " << num_cookies << " cookies";
  25. //
  26. // Most `Y_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 Y_ABSL_* prefix.
  32. #ifndef Y_ABSL_LOG_ABSL_LOG_H_
  33. #define Y_ABSL_LOG_ABSL_LOG_H_
  34. #include "y_absl/log/internal/log_impl.h"
  35. #define Y_ABSL_LOG(severity) Y_ABSL_LOG_INTERNAL_LOG_IMPL(_##severity)
  36. #define Y_ABSL_PLOG(severity) Y_ABSL_LOG_INTERNAL_PLOG_IMPL(_##severity)
  37. #define Y_ABSL_DLOG(severity) Y_ABSL_LOG_INTERNAL_DLOG_IMPL(_##severity)
  38. #define Y_ABSL_VLOG(verbose_level) Y_ABSL_LOG_INTERNAL_VLOG_IMPL(verbose_level)
  39. #define Y_ABSL_DVLOG(verbose_level) Y_ABSL_LOG_INTERNAL_DVLOG_IMPL(verbose_level)
  40. #define Y_ABSL_LOG_IF(severity, condition) \
  41. Y_ABSL_LOG_INTERNAL_LOG_IF_IMPL(_##severity, condition)
  42. #define Y_ABSL_PLOG_IF(severity, condition) \
  43. Y_ABSL_LOG_INTERNAL_PLOG_IF_IMPL(_##severity, condition)
  44. #define Y_ABSL_DLOG_IF(severity, condition) \
  45. Y_ABSL_LOG_INTERNAL_DLOG_IF_IMPL(_##severity, condition)
  46. #define Y_ABSL_LOG_EVERY_N(severity, n) \
  47. Y_ABSL_LOG_INTERNAL_LOG_EVERY_N_IMPL(_##severity, n)
  48. #define Y_ABSL_LOG_FIRST_N(severity, n) \
  49. Y_ABSL_LOG_INTERNAL_LOG_FIRST_N_IMPL(_##severity, n)
  50. #define Y_ABSL_LOG_EVERY_POW_2(severity) \
  51. Y_ABSL_LOG_INTERNAL_LOG_EVERY_POW_2_IMPL(_##severity)
  52. #define Y_ABSL_LOG_EVERY_N_SEC(severity, n_seconds) \
  53. Y_ABSL_LOG_INTERNAL_LOG_EVERY_N_SEC_IMPL(_##severity, n_seconds)
  54. #define Y_ABSL_PLOG_EVERY_N(severity, n) \
  55. Y_ABSL_LOG_INTERNAL_PLOG_EVERY_N_IMPL(_##severity, n)
  56. #define Y_ABSL_PLOG_FIRST_N(severity, n) \
  57. Y_ABSL_LOG_INTERNAL_PLOG_FIRST_N_IMPL(_##severity, n)
  58. #define Y_ABSL_PLOG_EVERY_POW_2(severity) \
  59. Y_ABSL_LOG_INTERNAL_PLOG_EVERY_POW_2_IMPL(_##severity)
  60. #define Y_ABSL_PLOG_EVERY_N_SEC(severity, n_seconds) \
  61. Y_ABSL_LOG_INTERNAL_PLOG_EVERY_N_SEC_IMPL(_##severity, n_seconds)
  62. #define Y_ABSL_DLOG_EVERY_N(severity, n) \
  63. Y_ABSL_LOG_INTERNAL_DLOG_EVERY_N_IMPL(_##severity, n)
  64. #define Y_ABSL_DLOG_FIRST_N(severity, n) \
  65. Y_ABSL_LOG_INTERNAL_DLOG_FIRST_N_IMPL(_##severity, n)
  66. #define Y_ABSL_DLOG_EVERY_POW_2(severity) \
  67. Y_ABSL_LOG_INTERNAL_DLOG_EVERY_POW_2_IMPL(_##severity)
  68. #define Y_ABSL_DLOG_EVERY_N_SEC(severity, n_seconds) \
  69. Y_ABSL_LOG_INTERNAL_DLOG_EVERY_N_SEC_IMPL(_##severity, n_seconds)
  70. #define Y_ABSL_VLOG_EVERY_N(verbose_level, n) \
  71. Y_ABSL_LOG_INTERNAL_VLOG_EVERY_N_IMPL(verbose_level, n)
  72. #define Y_ABSL_VLOG_FIRST_N(verbose_level, n) \
  73. Y_ABSL_LOG_INTERNAL_VLOG_FIRST_N_IMPL(verbose_level, n)
  74. #define Y_ABSL_VLOG_EVERY_POW_2(verbose_level, n) \
  75. Y_ABSL_LOG_INTERNAL_VLOG_EVERY_POW_2_IMPL(verbose_level, n)
  76. #define Y_ABSL_VLOG_EVERY_N_SEC(verbose_level, n) \
  77. Y_ABSL_LOG_INTERNAL_VLOG_EVERY_N_SEC_IMPL(verbose_level, n)
  78. #define Y_ABSL_LOG_IF_EVERY_N(severity, condition, n) \
  79. Y_ABSL_LOG_INTERNAL_LOG_IF_EVERY_N_IMPL(_##severity, condition, n)
  80. #define Y_ABSL_LOG_IF_FIRST_N(severity, condition, n) \
  81. Y_ABSL_LOG_INTERNAL_LOG_IF_FIRST_N_IMPL(_##severity, condition, n)
  82. #define Y_ABSL_LOG_IF_EVERY_POW_2(severity, condition) \
  83. Y_ABSL_LOG_INTERNAL_LOG_IF_EVERY_POW_2_IMPL(_##severity, condition)
  84. #define Y_ABSL_LOG_IF_EVERY_N_SEC(severity, condition, n_seconds) \
  85. Y_ABSL_LOG_INTERNAL_LOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds)
  86. #define Y_ABSL_PLOG_IF_EVERY_N(severity, condition, n) \
  87. Y_ABSL_LOG_INTERNAL_PLOG_IF_EVERY_N_IMPL(_##severity, condition, n)
  88. #define Y_ABSL_PLOG_IF_FIRST_N(severity, condition, n) \
  89. Y_ABSL_LOG_INTERNAL_PLOG_IF_FIRST_N_IMPL(_##severity, condition, n)
  90. #define Y_ABSL_PLOG_IF_EVERY_POW_2(severity, condition) \
  91. Y_ABSL_LOG_INTERNAL_PLOG_IF_EVERY_POW_2_IMPL(_##severity, condition)
  92. #define Y_ABSL_PLOG_IF_EVERY_N_SEC(severity, condition, n_seconds) \
  93. Y_ABSL_LOG_INTERNAL_PLOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds)
  94. #define Y_ABSL_DLOG_IF_EVERY_N(severity, condition, n) \
  95. Y_ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_IMPL(_##severity, condition, n)
  96. #define Y_ABSL_DLOG_IF_FIRST_N(severity, condition, n) \
  97. Y_ABSL_LOG_INTERNAL_DLOG_IF_FIRST_N_IMPL(_##severity, condition, n)
  98. #define Y_ABSL_DLOG_IF_EVERY_POW_2(severity, condition) \
  99. Y_ABSL_LOG_INTERNAL_DLOG_IF_EVERY_POW_2_IMPL(_##severity, condition)
  100. #define Y_ABSL_DLOG_IF_EVERY_N_SEC(severity, condition, n_seconds) \
  101. Y_ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds)
  102. #endif // Y_ABSL_LOG_ABSL_LOG_H_