Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:40:53

0001 // Copyright 2022 The Abseil Authors
0002 //
0003 // Licensed under the Apache License, Version 2.0 (the "License");
0004 // you may not use this file except in compliance with the License.
0005 // You may obtain a copy of the License at
0006 //
0007 //     https://www.apache.org/licenses/LICENSE-2.0
0008 //
0009 // Unless required by applicable law or agreed to in writing, software
0010 // distributed under the License is distributed on an "AS IS" BASIS,
0011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0012 // See the License for the specific language governing permissions and
0013 // limitations under the License.
0014 
0015 #ifndef ABSL_LOG_INTERNAL_LOG_IMPL_H_
0016 #define ABSL_LOG_INTERNAL_LOG_IMPL_H_
0017 
0018 #include "absl/log/absl_vlog_is_on.h"
0019 #include "absl/log/internal/conditions.h"
0020 #include "absl/log/internal/log_message.h"
0021 #include "absl/log/internal/strip.h"
0022 
0023 // ABSL_LOG()
0024 #define ABSL_LOG_INTERNAL_LOG_IMPL(severity)             \
0025   ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, true) \
0026       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
0027 
0028 // ABSL_PLOG()
0029 #define ABSL_LOG_INTERNAL_PLOG_IMPL(severity)              \
0030   ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, true)   \
0031       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() \
0032           .WithPerror()
0033 
0034 // ABSL_DLOG()
0035 #ifndef NDEBUG
0036 #define ABSL_LOG_INTERNAL_DLOG_IMPL(severity)            \
0037   ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, true) \
0038       ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
0039 #else
0040 #define ABSL_LOG_INTERNAL_DLOG_IMPL(severity)             \
0041   ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, false) \
0042       ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
0043 #endif
0044 
0045 // The `switch` ensures that this expansion is the beginning of a statement (as
0046 // opposed to an expression). The use of both `case 0` and `default` is to
0047 // suppress a compiler warning.
0048 #define ABSL_LOG_INTERNAL_VLOG_IMPL(verbose_level)                         \
0049   switch (const int absl_logging_internal_verbose_level = (verbose_level)) \
0050   case 0:                                                                  \
0051   default:                                                                 \
0052     ABSL_LOG_INTERNAL_LOG_IF_IMPL(                                         \
0053         _INFO, ABSL_VLOG_IS_ON(absl_logging_internal_verbose_level))       \
0054         .WithVerbosity(absl_logging_internal_verbose_level)
0055 
0056 #ifndef NDEBUG
0057 #define ABSL_LOG_INTERNAL_DVLOG_IMPL(verbose_level)                        \
0058   switch (const int absl_logging_internal_verbose_level = (verbose_level)) \
0059   case 0:                                                                  \
0060   default:                                                                 \
0061     ABSL_LOG_INTERNAL_DLOG_IF_IMPL(                                         \
0062         _INFO, ABSL_VLOG_IS_ON(absl_logging_internal_verbose_level))       \
0063         .WithVerbosity(absl_logging_internal_verbose_level)
0064 #else
0065 #define ABSL_LOG_INTERNAL_DVLOG_IMPL(verbose_level)                           \
0066   switch (const int absl_logging_internal_verbose_level = (verbose_level))    \
0067   case 0:                                                                     \
0068   default:                                                                    \
0069     ABSL_LOG_INTERNAL_DLOG_IF_IMPL(                                            \
0070         _INFO, false && ABSL_VLOG_IS_ON(absl_logging_internal_verbose_level)) \
0071         .WithVerbosity(absl_logging_internal_verbose_level)
0072 #endif
0073 
0074 #define ABSL_LOG_INTERNAL_LOG_IF_IMPL(severity, condition)    \
0075   ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, condition) \
0076       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
0077 #define ABSL_LOG_INTERNAL_PLOG_IF_IMPL(severity, condition)   \
0078   ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, condition) \
0079       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()    \
0080           .WithPerror()
0081 
0082 #ifndef NDEBUG
0083 #define ABSL_LOG_INTERNAL_DLOG_IF_IMPL(severity, condition)   \
0084   ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, condition) \
0085       ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
0086 #else
0087 #define ABSL_LOG_INTERNAL_DLOG_IF_IMPL(severity, condition)              \
0088   ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, false && (condition)) \
0089       ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
0090 #endif
0091 
0092 // ABSL_LOG_EVERY_N
0093 #define ABSL_LOG_INTERNAL_LOG_EVERY_N_IMPL(severity, n)            \
0094   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(EveryN, n) \
0095       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
0096 
0097 // ABSL_LOG_FIRST_N
0098 #define ABSL_LOG_INTERNAL_LOG_FIRST_N_IMPL(severity, n)            \
0099   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(FirstN, n) \
0100       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
0101 
0102 // ABSL_LOG_EVERY_POW_2
0103 #define ABSL_LOG_INTERNAL_LOG_EVERY_POW_2_IMPL(severity)           \
0104   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(EveryPow2) \
0105       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
0106 
0107 // ABSL_LOG_EVERY_N_SEC
0108 #define ABSL_LOG_INTERNAL_LOG_EVERY_N_SEC_IMPL(severity, n_seconds)           \
0109   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(EveryNSec, n_seconds) \
0110       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
0111 
0112 #define ABSL_LOG_INTERNAL_PLOG_EVERY_N_IMPL(severity, n)           \
0113   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(EveryN, n) \
0114       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()         \
0115           .WithPerror()
0116 
0117 #define ABSL_LOG_INTERNAL_PLOG_FIRST_N_IMPL(severity, n)           \
0118   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(FirstN, n) \
0119       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()         \
0120           .WithPerror()
0121 
0122 #define ABSL_LOG_INTERNAL_PLOG_EVERY_POW_2_IMPL(severity)          \
0123   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(EveryPow2) \
0124       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()         \
0125           .WithPerror()
0126 
0127 #define ABSL_LOG_INTERNAL_PLOG_EVERY_N_SEC_IMPL(severity, n_seconds)          \
0128   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(EveryNSec, n_seconds) \
0129       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()                    \
0130           .WithPerror()
0131 
0132 #ifndef NDEBUG
0133 #define ABSL_LOG_INTERNAL_DLOG_EVERY_N_IMPL(severity, n) \
0134   ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, true)       \
0135   (EveryN, n) ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
0136 
0137 #define ABSL_LOG_INTERNAL_DLOG_FIRST_N_IMPL(severity, n) \
0138   ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, true)       \
0139   (FirstN, n) ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
0140 
0141 #define ABSL_LOG_INTERNAL_DLOG_EVERY_POW_2_IMPL(severity) \
0142   ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, true)        \
0143   (EveryPow2) ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
0144 
0145 #define ABSL_LOG_INTERNAL_DLOG_EVERY_N_SEC_IMPL(severity, n_seconds) \
0146   ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, true)                   \
0147   (EveryNSec, n_seconds) ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
0148 
0149 #else  // def NDEBUG
0150 #define ABSL_LOG_INTERNAL_DLOG_EVERY_N_IMPL(severity, n) \
0151   ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, false)      \
0152   (EveryN, n) ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
0153 
0154 #define ABSL_LOG_INTERNAL_DLOG_FIRST_N_IMPL(severity, n) \
0155   ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, false)      \
0156   (FirstN, n) ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
0157 
0158 #define ABSL_LOG_INTERNAL_DLOG_EVERY_POW_2_IMPL(severity) \
0159   ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, false)       \
0160   (EveryPow2) ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
0161 
0162 #define ABSL_LOG_INTERNAL_DLOG_EVERY_N_SEC_IMPL(severity, n_seconds) \
0163   ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, false)                  \
0164   (EveryNSec, n_seconds) ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
0165 #endif  // def NDEBUG
0166 
0167 #define ABSL_LOG_INTERNAL_VLOG_EVERY_N_IMPL(verbose_level, n)                \
0168   switch (const int absl_logging_internal_verbose_level = (verbose_level))   \
0169   case 0:                                                                    \
0170   default:                                                                   \
0171     ABSL_LOG_INTERNAL_CONDITION_INFO(                                        \
0172         STATEFUL, ABSL_VLOG_IS_ON(absl_logging_internal_verbose_level))      \
0173   (EveryN, n) ABSL_LOGGING_INTERNAL_LOG_INFO.InternalStream().WithVerbosity( \
0174       absl_logging_internal_verbose_level)
0175 
0176 #define ABSL_LOG_INTERNAL_VLOG_FIRST_N_IMPL(verbose_level, n)                \
0177   switch (const int absl_logging_internal_verbose_level = (verbose_level))   \
0178   case 0:                                                                    \
0179   default:                                                                   \
0180     ABSL_LOG_INTERNAL_CONDITION_INFO(                                        \
0181         STATEFUL, ABSL_VLOG_IS_ON(absl_logging_internal_verbose_level))      \
0182   (FirstN, n) ABSL_LOGGING_INTERNAL_LOG_INFO.InternalStream().WithVerbosity( \
0183       absl_logging_internal_verbose_level)
0184 
0185 #define ABSL_LOG_INTERNAL_VLOG_EVERY_POW_2_IMPL(verbose_level)               \
0186   switch (const int absl_logging_internal_verbose_level = (verbose_level))   \
0187   case 0:                                                                    \
0188   default:                                                                   \
0189     ABSL_LOG_INTERNAL_CONDITION_INFO(                                        \
0190         STATEFUL, ABSL_VLOG_IS_ON(absl_logging_internal_verbose_level))      \
0191   (EveryPow2) ABSL_LOGGING_INTERNAL_LOG_INFO.InternalStream().WithVerbosity( \
0192       absl_logging_internal_verbose_level)
0193 
0194 #define ABSL_LOG_INTERNAL_VLOG_EVERY_N_SEC_IMPL(verbose_level, n_seconds)  \
0195   switch (const int absl_logging_internal_verbose_level = (verbose_level)) \
0196   case 0:                                                                  \
0197   default:                                                                 \
0198     ABSL_LOG_INTERNAL_CONDITION_INFO(                                      \
0199         STATEFUL, ABSL_VLOG_IS_ON(absl_logging_internal_verbose_level))    \
0200   (EveryNSec, n_seconds) ABSL_LOGGING_INTERNAL_LOG_INFO.InternalStream()   \
0201       .WithVerbosity(absl_logging_internal_verbose_level)
0202 
0203 #define ABSL_LOG_INTERNAL_LOG_IF_EVERY_N_IMPL(severity, condition, n)   \
0204   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryN, n) \
0205       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
0206 
0207 #define ABSL_LOG_INTERNAL_LOG_IF_FIRST_N_IMPL(severity, condition, n)   \
0208   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(FirstN, n) \
0209       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
0210 
0211 #define ABSL_LOG_INTERNAL_LOG_IF_EVERY_POW_2_IMPL(severity, condition)  \
0212   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryPow2) \
0213       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
0214 
0215 #define ABSL_LOG_INTERNAL_LOG_IF_EVERY_N_SEC_IMPL(severity, condition,  \
0216                                                   n_seconds)            \
0217   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryNSec, \
0218                                                              n_seconds) \
0219       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()
0220 
0221 #define ABSL_LOG_INTERNAL_PLOG_IF_EVERY_N_IMPL(severity, condition, n)  \
0222   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryN, n) \
0223       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()              \
0224           .WithPerror()
0225 
0226 #define ABSL_LOG_INTERNAL_PLOG_IF_FIRST_N_IMPL(severity, condition, n)  \
0227   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(FirstN, n) \
0228       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()              \
0229           .WithPerror()
0230 
0231 #define ABSL_LOG_INTERNAL_PLOG_IF_EVERY_POW_2_IMPL(severity, condition) \
0232   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryPow2) \
0233       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()              \
0234           .WithPerror()
0235 
0236 #define ABSL_LOG_INTERNAL_PLOG_IF_EVERY_N_SEC_IMPL(severity, condition, \
0237                                                    n_seconds)           \
0238   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryNSec, \
0239                                                              n_seconds) \
0240       ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream()              \
0241           .WithPerror()
0242 
0243 #ifndef NDEBUG
0244 #define ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_IMPL(severity, condition, n)  \
0245   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryN, n) \
0246       ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
0247 
0248 #define ABSL_LOG_INTERNAL_DLOG_IF_FIRST_N_IMPL(severity, condition, n)  \
0249   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(FirstN, n) \
0250       ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
0251 
0252 #define ABSL_LOG_INTERNAL_DLOG_IF_EVERY_POW_2_IMPL(severity, condition) \
0253   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryPow2) \
0254       ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
0255 
0256 #define ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_SEC_IMPL(severity, condition, \
0257                                                    n_seconds)           \
0258   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryNSec, \
0259                                                              n_seconds) \
0260       ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
0261 
0262 #else  // def NDEBUG
0263 #define ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_IMPL(severity, condition, n)   \
0264   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, false && (condition))( \
0265       EveryN, n) ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
0266 
0267 #define ABSL_LOG_INTERNAL_DLOG_IF_FIRST_N_IMPL(severity, condition, n)   \
0268   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, false && (condition))( \
0269       FirstN, n) ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
0270 
0271 #define ABSL_LOG_INTERNAL_DLOG_IF_EVERY_POW_2_IMPL(severity, condition)  \
0272   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, false && (condition))( \
0273       EveryPow2) ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
0274 
0275 #define ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_SEC_IMPL(severity, condition,  \
0276                                                    n_seconds)            \
0277   ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, false && (condition))( \
0278       EveryNSec, n_seconds)                                              \
0279       ABSL_LOGGING_INTERNAL_DLOG##severity.InternalStream()
0280 #endif  // def NDEBUG
0281 
0282 #endif  // ABSL_LOG_INTERNAL_LOG_IMPL_H_