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 33 #ifndef ABSL_LOG_ABSL_LOG_H_ 34 #define ABSL_LOG_ABSL_LOG_H_ 35 36 #include "absl/log/internal/log_impl.h" 37 38 #define ABSL_LOG(severity) ABSL_LOG_INTERNAL_LOG_IMPL(_##severity) 39 #define ABSL_PLOG(severity) ABSL_LOG_INTERNAL_PLOG_IMPL(_##severity) 40 #define ABSL_DLOG(severity) ABSL_LOG_INTERNAL_DLOG_IMPL(_##severity) 41 42 #define ABSL_VLOG(verbose_level) ABSL_LOG_INTERNAL_VLOG_IMPL(verbose_level) 43 #define ABSL_DVLOG(verbose_level) ABSL_LOG_INTERNAL_DVLOG_IMPL(verbose_level) 44 45 #define ABSL_LOG_IF(severity, condition) \ 46 ABSL_LOG_INTERNAL_LOG_IF_IMPL(_##severity, condition) 47 #define ABSL_PLOG_IF(severity, condition) \ 48 ABSL_LOG_INTERNAL_PLOG_IF_IMPL(_##severity, condition) 49 #define ABSL_DLOG_IF(severity, condition) \ 50 ABSL_LOG_INTERNAL_DLOG_IF_IMPL(_##severity, condition) 51 52 #define ABSL_LOG_EVERY_N(severity, n) \ 53 ABSL_LOG_INTERNAL_LOG_EVERY_N_IMPL(_##severity, n) 54 #define ABSL_LOG_FIRST_N(severity, n) \ 55 ABSL_LOG_INTERNAL_LOG_FIRST_N_IMPL(_##severity, n) 56 #define ABSL_LOG_EVERY_POW_2(severity) \ 57 ABSL_LOG_INTERNAL_LOG_EVERY_POW_2_IMPL(_##severity) 58 #define ABSL_LOG_EVERY_N_SEC(severity, n_seconds) \ 59 ABSL_LOG_INTERNAL_LOG_EVERY_N_SEC_IMPL(_##severity, n_seconds) 60 61 #define ABSL_PLOG_EVERY_N(severity, n) \ 62 ABSL_LOG_INTERNAL_PLOG_EVERY_N_IMPL(_##severity, n) 63 #define ABSL_PLOG_FIRST_N(severity, n) \ 64 ABSL_LOG_INTERNAL_PLOG_FIRST_N_IMPL(_##severity, n) 65 #define ABSL_PLOG_EVERY_POW_2(severity) \ 66 ABSL_LOG_INTERNAL_PLOG_EVERY_POW_2_IMPL(_##severity) 67 #define ABSL_PLOG_EVERY_N_SEC(severity, n_seconds) \ 68 ABSL_LOG_INTERNAL_PLOG_EVERY_N_SEC_IMPL(_##severity, n_seconds) 69 70 #define ABSL_DLOG_EVERY_N(severity, n) \ 71 ABSL_LOG_INTERNAL_DLOG_EVERY_N_IMPL(_##severity, n) 72 #define ABSL_DLOG_FIRST_N(severity, n) \ 73 ABSL_LOG_INTERNAL_DLOG_FIRST_N_IMPL(_##severity, n) 74 #define ABSL_DLOG_EVERY_POW_2(severity) \ 75 ABSL_LOG_INTERNAL_DLOG_EVERY_POW_2_IMPL(_##severity) 76 #define ABSL_DLOG_EVERY_N_SEC(severity, n_seconds) \ 77 ABSL_LOG_INTERNAL_DLOG_EVERY_N_SEC_IMPL(_##severity, n_seconds) 78 79 #define ABSL_VLOG_EVERY_N(verbose_level, n) \ 80 ABSL_LOG_INTERNAL_VLOG_EVERY_N_IMPL(verbose_level, n) 81 #define ABSL_VLOG_FIRST_N(verbose_level, n) \ 82 ABSL_LOG_INTERNAL_VLOG_FIRST_N_IMPL(verbose_level, n) 83 #define ABSL_VLOG_EVERY_POW_2(verbose_level, n) \ 84 ABSL_LOG_INTERNAL_VLOG_EVERY_POW_2_IMPL(verbose_level, n) 85 #define ABSL_VLOG_EVERY_N_SEC(verbose_level, n) \ 86 ABSL_LOG_INTERNAL_VLOG_EVERY_N_SEC_IMPL(verbose_level, n) 87 88 #define ABSL_LOG_IF_EVERY_N(severity, condition, n) \ 89 ABSL_LOG_INTERNAL_LOG_IF_EVERY_N_IMPL(_##severity, condition, n) 90 #define ABSL_LOG_IF_FIRST_N(severity, condition, n) \ 91 ABSL_LOG_INTERNAL_LOG_IF_FIRST_N_IMPL(_##severity, condition, n) 92 #define ABSL_LOG_IF_EVERY_POW_2(severity, condition) \ 93 ABSL_LOG_INTERNAL_LOG_IF_EVERY_POW_2_IMPL(_##severity, condition) 94 #define ABSL_LOG_IF_EVERY_N_SEC(severity, condition, n_seconds) \ 95 ABSL_LOG_INTERNAL_LOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds) 96 97 #define ABSL_PLOG_IF_EVERY_N(severity, condition, n) \ 98 ABSL_LOG_INTERNAL_PLOG_IF_EVERY_N_IMPL(_##severity, condition, n) 99 #define ABSL_PLOG_IF_FIRST_N(severity, condition, n) \ 100 ABSL_LOG_INTERNAL_PLOG_IF_FIRST_N_IMPL(_##severity, condition, n) 101 #define ABSL_PLOG_IF_EVERY_POW_2(severity, condition) \ 102 ABSL_LOG_INTERNAL_PLOG_IF_EVERY_POW_2_IMPL(_##severity, condition) 103 #define ABSL_PLOG_IF_EVERY_N_SEC(severity, condition, n_seconds) \ 104 ABSL_LOG_INTERNAL_PLOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds) 105 106 #define ABSL_DLOG_IF_EVERY_N(severity, condition, n) \ 107 ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_IMPL(_##severity, condition, n) 108 #define ABSL_DLOG_IF_FIRST_N(severity, condition, n) \ 109 ABSL_LOG_INTERNAL_DLOG_IF_FIRST_N_IMPL(_##severity, condition, n) 110 #define ABSL_DLOG_IF_EVERY_POW_2(severity, condition) \ 111 ABSL_LOG_INTERNAL_DLOG_IF_EVERY_POW_2_IMPL(_##severity, condition) 112 #define ABSL_DLOG_IF_EVERY_N_SEC(severity, condition, n_seconds) \ 113 ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds) 114 115 #endif // ABSL_LOG_ABSL_LOG_H_ 116