diff options
author | Andy Getzendanner <durandal@google.com> | 2023-05-19 18:53:34 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-05-19 18:54:21 -0700 |
commit | 68be7315913c8ef8a791a0fb60d98e98787d88b6 (patch) | |
tree | 9a5b3fec68e69ec6c37e28db407ba04872626440 /absl | |
parent | 15d26cdd0179f83b328f3b62ae7d08388ffeef0b (diff) |
Rename ABSL_*_IMPL macros to match the other ABSL_LOG_INTERNAL_* macros and to make sure it's clear that they're internal.
Also rename the log and check test files from .h to .inc per https://google.github.io/styleguide/cppguide.html#Self_contained_Headers.
PiperOrigin-RevId: 533603350
Change-Id: Iad5d8b683e33b63784cc8e64b84da09f5fc3bf1e
Diffstat (limited to 'absl')
-rw-r--r-- | absl/log/BUILD.bazel | 4 | ||||
-rw-r--r-- | absl/log/CMakeLists.txt | 9 | ||||
-rw-r--r-- | absl/log/absl_check.h | 86 | ||||
-rw-r--r-- | absl/log/absl_check_test.cc | 2 | ||||
-rw-r--r-- | absl/log/absl_log.h | 69 | ||||
-rw-r--r-- | absl/log/absl_log_basic_test.cc | 2 | ||||
-rw-r--r-- | absl/log/check.h | 100 | ||||
-rw-r--r-- | absl/log/check_test.cc | 2 | ||||
-rw-r--r-- | absl/log/check_test_impl.inc (renamed from absl/log/check_test_impl.h) | 0 | ||||
-rw-r--r-- | absl/log/internal/check_impl.h | 126 | ||||
-rw-r--r-- | absl/log/internal/log_impl.h | 100 | ||||
-rw-r--r-- | absl/log/log.h | 72 | ||||
-rw-r--r-- | absl/log/log_basic_test.cc | 2 | ||||
-rw-r--r-- | absl/log/log_basic_test_impl.inc (renamed from absl/log/log_basic_test_impl.h) | 18 |
14 files changed, 327 insertions, 265 deletions
diff --git a/absl/log/BUILD.bazel b/absl/log/BUILD.bazel index 4813111f..560f6c44 100644 --- a/absl/log/BUILD.bazel +++ b/absl/log/BUILD.bazel @@ -289,7 +289,7 @@ cc_library( "no_test_ios", "no_test_wasm", ], - textual_hdrs = ["check_test_impl.h"], + textual_hdrs = ["check_test_impl.inc"], visibility = ["//visibility:private"], deps = [ "//absl/base:config", @@ -373,7 +373,7 @@ cc_library( testonly = True, copts = ABSL_TEST_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, - textual_hdrs = ["log_basic_test_impl.h"], + textual_hdrs = ["log_basic_test_impl.inc"], visibility = ["//visibility:private"], deps = [ "//absl/base", diff --git a/absl/log/CMakeLists.txt b/absl/log/CMakeLists.txt index 4cba0082..2990984f 100644 --- a/absl/log/CMakeLists.txt +++ b/absl/log/CMakeLists.txt @@ -1,4 +1,3 @@ -# # Copyright 2022 The Abseil Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -679,7 +678,7 @@ absl_cc_test( absl_check_test SRCS "absl_check_test.cc" - "check_test_impl.h" + "check_test_impl.inc" COPTS ${ABSL_TEST_COPTS} LINKOPTS @@ -699,7 +698,7 @@ absl_cc_test( absl_log_basic_test SRCS "log_basic_test.cc" - "log_basic_test_impl.h" + "log_basic_test_impl.inc" COPTS ${ABSL_TEST_COPTS} LINKOPTS @@ -723,7 +722,7 @@ absl_cc_test( check_test SRCS "check_test.cc" - "check_test_impl.h" + "check_test_impl.inc" COPTS ${ABSL_TEST_COPTS} LINKOPTS @@ -759,7 +758,7 @@ absl_cc_test( log_basic_test SRCS "log_basic_test.cc" - "log_basic_test_impl.h" + "log_basic_test_impl.inc" COPTS ${ABSL_TEST_COPTS} LINKOPTS diff --git a/absl/log/absl_check.h b/absl/log/absl_check.h index 14a2307f..1bb43bd3 100644 --- a/absl/log/absl_check.h +++ b/absl/log/absl_check.h @@ -37,69 +37,81 @@ #include "absl/log/internal/check_impl.h" -#define ABSL_CHECK(condition) ABSL_CHECK_IMPL((condition), #condition) -#define ABSL_QCHECK(condition) ABSL_QCHECK_IMPL((condition), #condition) -#define ABSL_PCHECK(condition) ABSL_PCHECK_IMPL((condition), #condition) -#define ABSL_DCHECK(condition) ABSL_DCHECK_IMPL((condition), #condition) +#define ABSL_CHECK(condition) \ + ABSL_LOG_INTERNAL_CHECK_IMPL((condition), #condition) +#define ABSL_QCHECK(condition) \ + ABSL_LOG_INTERNAL_QCHECK_IMPL((condition), #condition) +#define ABSL_PCHECK(condition) \ + ABSL_LOG_INTERNAL_PCHECK_IMPL((condition), #condition) +#define ABSL_DCHECK(condition) \ + ABSL_LOG_INTERNAL_DCHECK_IMPL((condition), #condition) #define ABSL_CHECK_EQ(val1, val2) \ - ABSL_CHECK_EQ_IMPL((val1), #val1, (val2), #val2) + ABSL_LOG_INTERNAL_CHECK_EQ_IMPL((val1), #val1, (val2), #val2) #define ABSL_CHECK_NE(val1, val2) \ - ABSL_CHECK_NE_IMPL((val1), #val1, (val2), #val2) + ABSL_LOG_INTERNAL_CHECK_NE_IMPL((val1), #val1, (val2), #val2) #define ABSL_CHECK_LE(val1, val2) \ - ABSL_CHECK_LE_IMPL((val1), #val1, (val2), #val2) + ABSL_LOG_INTERNAL_CHECK_LE_IMPL((val1), #val1, (val2), #val2) #define ABSL_CHECK_LT(val1, val2) \ - ABSL_CHECK_LT_IMPL((val1), #val1, (val2), #val2) + ABSL_LOG_INTERNAL_CHECK_LT_IMPL((val1), #val1, (val2), #val2) #define ABSL_CHECK_GE(val1, val2) \ - ABSL_CHECK_GE_IMPL((val1), #val1, (val2), #val2) + ABSL_LOG_INTERNAL_CHECK_GE_IMPL((val1), #val1, (val2), #val2) #define ABSL_CHECK_GT(val1, val2) \ - ABSL_CHECK_GT_IMPL((val1), #val1, (val2), #val2) + ABSL_LOG_INTERNAL_CHECK_GT_IMPL((val1), #val1, (val2), #val2) #define ABSL_QCHECK_EQ(val1, val2) \ - ABSL_QCHECK_EQ_IMPL((val1), #val1, (val2), #val2) + ABSL_LOG_INTERNAL_QCHECK_EQ_IMPL((val1), #val1, (val2), #val2) #define ABSL_QCHECK_NE(val1, val2) \ - ABSL_QCHECK_NE_IMPL((val1), #val1, (val2), #val2) + ABSL_LOG_INTERNAL_QCHECK_NE_IMPL((val1), #val1, (val2), #val2) #define ABSL_QCHECK_LE(val1, val2) \ - ABSL_QCHECK_LE_IMPL((val1), #val1, (val2), #val2) + ABSL_LOG_INTERNAL_QCHECK_LE_IMPL((val1), #val1, (val2), #val2) #define ABSL_QCHECK_LT(val1, val2) \ - ABSL_QCHECK_LT_IMPL((val1), #val1, (val2), #val2) + ABSL_LOG_INTERNAL_QCHECK_LT_IMPL((val1), #val1, (val2), #val2) #define ABSL_QCHECK_GE(val1, val2) \ - ABSL_QCHECK_GE_IMPL((val1), #val1, (val2), #val2) + ABSL_LOG_INTERNAL_QCHECK_GE_IMPL((val1), #val1, (val2), #val2) #define ABSL_QCHECK_GT(val1, val2) \ - ABSL_QCHECK_GT_IMPL((val1), #val1, (val2), #val2) + ABSL_LOG_INTERNAL_QCHECK_GT_IMPL((val1), #val1, (val2), #val2) #define ABSL_DCHECK_EQ(val1, val2) \ - ABSL_DCHECK_EQ_IMPL((val1), #val1, (val2), #val2) + ABSL_LOG_INTERNAL_DCHECK_EQ_IMPL((val1), #val1, (val2), #val2) #define ABSL_DCHECK_NE(val1, val2) \ - ABSL_DCHECK_NE_IMPL((val1), #val1, (val2), #val2) + ABSL_LOG_INTERNAL_DCHECK_NE_IMPL((val1), #val1, (val2), #val2) #define ABSL_DCHECK_LE(val1, val2) \ - ABSL_DCHECK_LE_IMPL((val1), #val1, (val2), #val2) + ABSL_LOG_INTERNAL_DCHECK_LE_IMPL((val1), #val1, (val2), #val2) #define ABSL_DCHECK_LT(val1, val2) \ - ABSL_DCHECK_LT_IMPL((val1), #val1, (val2), #val2) + ABSL_LOG_INTERNAL_DCHECK_LT_IMPL((val1), #val1, (val2), #val2) #define ABSL_DCHECK_GE(val1, val2) \ - ABSL_DCHECK_GE_IMPL((val1), #val1, (val2), #val2) + ABSL_LOG_INTERNAL_DCHECK_GE_IMPL((val1), #val1, (val2), #val2) #define ABSL_DCHECK_GT(val1, val2) \ - ABSL_DCHECK_GT_IMPL((val1), #val1, (val2), #val2) + ABSL_LOG_INTERNAL_DCHECK_GT_IMPL((val1), #val1, (val2), #val2) -#define ABSL_CHECK_OK(status) ABSL_CHECK_OK_IMPL((status), #status) -#define ABSL_QCHECK_OK(status) ABSL_QCHECK_OK_IMPL((status), #status) -#define ABSL_DCHECK_OK(status) ABSL_DCHECK_OK_IMPL((status), #status) +#define ABSL_CHECK_OK(status) ABSL_LOG_INTERNAL_CHECK_OK_IMPL((status), #status) +#define ABSL_QCHECK_OK(status) \ + ABSL_LOG_INTERNAL_QCHECK_OK_IMPL((status), #status) +#define ABSL_DCHECK_OK(status) \ + ABSL_LOG_INTERNAL_DCHECK_OK_IMPL((status), #status) -#define ABSL_CHECK_STREQ(s1, s2) ABSL_CHECK_STREQ_IMPL((s1), #s1, (s2), #s2) -#define ABSL_CHECK_STRNE(s1, s2) ABSL_CHECK_STRNE_IMPL((s1), #s1, (s2), #s2) +#define ABSL_CHECK_STREQ(s1, s2) \ + ABSL_LOG_INTERNAL_CHECK_STREQ_IMPL((s1), #s1, (s2), #s2) +#define ABSL_CHECK_STRNE(s1, s2) \ + ABSL_LOG_INTERNAL_CHECK_STRNE_IMPL((s1), #s1, (s2), #s2) #define ABSL_CHECK_STRCASEEQ(s1, s2) \ - ABSL_CHECK_STRCASEEQ_IMPL((s1), #s1, (s2), #s2) + ABSL_LOG_INTERNAL_CHECK_STRCASEEQ_IMPL((s1), #s1, (s2), #s2) #define ABSL_CHECK_STRCASENE(s1, s2) \ - ABSL_CHECK_STRCASENE_IMPL((s1), #s1, (s2), #s2) -#define ABSL_QCHECK_STREQ(s1, s2) ABSL_QCHECK_STREQ_IMPL((s1), #s1, (s2), #s2) -#define ABSL_QCHECK_STRNE(s1, s2) ABSL_QCHECK_STRNE_IMPL((s1), #s1, (s2), #s2) + ABSL_LOG_INTERNAL_CHECK_STRCASENE_IMPL((s1), #s1, (s2), #s2) +#define ABSL_QCHECK_STREQ(s1, s2) \ + ABSL_LOG_INTERNAL_QCHECK_STREQ_IMPL((s1), #s1, (s2), #s2) +#define ABSL_QCHECK_STRNE(s1, s2) \ + ABSL_LOG_INTERNAL_QCHECK_STRNE_IMPL((s1), #s1, (s2), #s2) #define ABSL_QCHECK_STRCASEEQ(s1, s2) \ - ABSL_QCHECK_STRCASEEQ_IMPL((s1), #s1, (s2), #s2) + ABSL_LOG_INTERNAL_QCHECK_STRCASEEQ_IMPL((s1), #s1, (s2), #s2) #define ABSL_QCHECK_STRCASENE(s1, s2) \ - ABSL_QCHECK_STRCASENE_IMPL((s1), #s1, (s2), #s2) -#define ABSL_DCHECK_STREQ(s1, s2) ABSL_DCHECK_STREQ_IMPL((s1), #s1, (s2), #s2) -#define ABSL_DCHECK_STRNE(s1, s2) ABSL_DCHECK_STRNE_IMPL((s1), #s1, (s2), #s2) + ABSL_LOG_INTERNAL_QCHECK_STRCASENE_IMPL((s1), #s1, (s2), #s2) +#define ABSL_DCHECK_STREQ(s1, s2) \ + ABSL_LOG_INTERNAL_DCHECK_STREQ_IMPL((s1), #s1, (s2), #s2) +#define ABSL_DCHECK_STRNE(s1, s2) \ + ABSL_LOG_INTERNAL_DCHECK_STRNE_IMPL((s1), #s1, (s2), #s2) #define ABSL_DCHECK_STRCASEEQ(s1, s2) \ - ABSL_DCHECK_STRCASEEQ_IMPL((s1), #s1, (s2), #s2) + ABSL_LOG_INTERNAL_DCHECK_STRCASEEQ_IMPL((s1), #s1, (s2), #s2) #define ABSL_DCHECK_STRCASENE(s1, s2) \ - ABSL_DCHECK_STRCASENE_IMPL((s1), #s1, (s2), #s2) + ABSL_LOG_INTERNAL_DCHECK_STRCASENE_IMPL((s1), #s1, (s2), #s2) #endif // ABSL_LOG_ABSL_CHECK_H_ diff --git a/absl/log/absl_check_test.cc b/absl/log/absl_check_test.cc index 8ddacdb1..d84940fa 100644 --- a/absl/log/absl_check_test.cc +++ b/absl/log/absl_check_test.cc @@ -55,4 +55,4 @@ #define ABSL_TEST_QCHECK_STRCASENE ABSL_QCHECK_STRCASENE #include "gtest/gtest.h" -#include "absl/log/check_test_impl.h" +#include "absl/log/check_test_impl.inc" diff --git a/absl/log/absl_log.h b/absl/log/absl_log.h index 1c6cf263..0517760b 100644 --- a/absl/log/absl_log.h +++ b/absl/log/absl_log.h @@ -35,60 +35,69 @@ #include "absl/log/internal/log_impl.h" -#define ABSL_LOG(severity) ABSL_LOG_IMPL(_##severity) -#define ABSL_PLOG(severity) ABSL_PLOG_IMPL(_##severity) -#define ABSL_DLOG(severity) ABSL_DLOG_IMPL(_##severity) +#define ABSL_LOG(severity) ABSL_LOG_INTERNAL_LOG_IMPL(_##severity) +#define ABSL_PLOG(severity) ABSL_LOG_INTERNAL_PLOG_IMPL(_##severity) +#define ABSL_DLOG(severity) ABSL_LOG_INTERNAL_DLOG_IMPL(_##severity) #define ABSL_LOG_IF(severity, condition) \ - ABSL_LOG_IF_IMPL(_##severity, condition) + ABSL_LOG_INTERNAL_LOG_IF_IMPL(_##severity, condition) #define ABSL_PLOG_IF(severity, condition) \ - ABSL_PLOG_IF_IMPL(_##severity, condition) + ABSL_LOG_INTERNAL_PLOG_IF_IMPL(_##severity, condition) #define ABSL_DLOG_IF(severity, condition) \ - ABSL_DLOG_IF_IMPL(_##severity, condition) + ABSL_LOG_INTERNAL_DLOG_IF_IMPL(_##severity, condition) -#define ABSL_LOG_EVERY_N(severity, n) ABSL_LOG_EVERY_N_IMPL(_##severity, n) -#define ABSL_LOG_FIRST_N(severity, n) ABSL_LOG_FIRST_N_IMPL(_##severity, n) -#define ABSL_LOG_EVERY_POW_2(severity) ABSL_LOG_EVERY_POW_2_IMPL(_##severity) +#define ABSL_LOG_EVERY_N(severity, n) \ + ABSL_LOG_INTERNAL_LOG_EVERY_N_IMPL(_##severity, n) +#define ABSL_LOG_FIRST_N(severity, n) \ + ABSL_LOG_INTERNAL_LOG_FIRST_N_IMPL(_##severity, n) +#define ABSL_LOG_EVERY_POW_2(severity) \ + ABSL_LOG_INTERNAL_LOG_EVERY_POW_2_IMPL(_##severity) #define ABSL_LOG_EVERY_N_SEC(severity, n_seconds) \ - ABSL_LOG_EVERY_N_SEC_IMPL(_##severity, n_seconds) + ABSL_LOG_INTERNAL_LOG_EVERY_N_SEC_IMPL(_##severity, n_seconds) -#define ABSL_PLOG_EVERY_N(severity, n) ABSL_PLOG_EVERY_N_IMPL(_##severity, n) -#define ABSL_PLOG_FIRST_N(severity, n) ABSL_PLOG_FIRST_N_IMPL(_##severity, n) -#define ABSL_PLOG_EVERY_POW_2(severity) ABSL_PLOG_EVERY_POW_2_IMPL(_##severity) +#define ABSL_PLOG_EVERY_N(severity, n) \ + ABSL_LOG_INTERNAL_PLOG_EVERY_N_IMPL(_##severity, n) +#define ABSL_PLOG_FIRST_N(severity, n) \ + ABSL_LOG_INTERNAL_PLOG_FIRST_N_IMPL(_##severity, n) +#define ABSL_PLOG_EVERY_POW_2(severity) \ + ABSL_LOG_INTERNAL_PLOG_EVERY_POW_2_IMPL(_##severity) #define ABSL_PLOG_EVERY_N_SEC(severity, n_seconds) \ - ABSL_PLOG_EVERY_N_SEC_IMPL(_##severity, n_seconds) + ABSL_LOG_INTERNAL_PLOG_EVERY_N_SEC_IMPL(_##severity, n_seconds) -#define ABSL_DLOG_EVERY_N(severity, n) ABSL_DLOG_EVERY_N_IMPL(_##severity, n) -#define ABSL_DLOG_FIRST_N(severity, n) ABSL_DLOG_FIRST_N_IMPL(_##severity, n) -#define ABSL_DLOG_EVERY_POW_2(severity) ABSL_DLOG_EVERY_POW_2_IMPL(_##severity) +#define ABSL_DLOG_EVERY_N(severity, n) \ + ABSL_LOG_INTERNAL_DLOG_EVERY_N_IMPL(_##severity, n) +#define ABSL_DLOG_FIRST_N(severity, n) \ + ABSL_LOG_INTERNAL_DLOG_FIRST_N_IMPL(_##severity, n) +#define ABSL_DLOG_EVERY_POW_2(severity) \ + ABSL_LOG_INTERNAL_DLOG_EVERY_POW_2_IMPL(_##severity) #define ABSL_DLOG_EVERY_N_SEC(severity, n_seconds) \ - ABSL_DLOG_EVERY_N_SEC_IMPL(_##severity, n_seconds) + ABSL_LOG_INTERNAL_DLOG_EVERY_N_SEC_IMPL(_##severity, n_seconds) #define ABSL_LOG_IF_EVERY_N(severity, condition, n) \ - ABSL_LOG_IF_EVERY_N_IMPL(_##severity, condition, n) + ABSL_LOG_INTERNAL_LOG_IF_EVERY_N_IMPL(_##severity, condition, n) #define ABSL_LOG_IF_FIRST_N(severity, condition, n) \ - ABSL_LOG_IF_FIRST_N_IMPL(_##severity, condition, n) + ABSL_LOG_INTERNAL_LOG_IF_FIRST_N_IMPL(_##severity, condition, n) #define ABSL_LOG_IF_EVERY_POW_2(severity, condition) \ - ABSL_LOG_IF_EVERY_POW_2_IMPL(_##severity, condition) + ABSL_LOG_INTERNAL_LOG_IF_EVERY_POW_2_IMPL(_##severity, condition) #define ABSL_LOG_IF_EVERY_N_SEC(severity, condition, n_seconds) \ - ABSL_LOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds) + ABSL_LOG_INTERNAL_LOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds) #define ABSL_PLOG_IF_EVERY_N(severity, condition, n) \ - ABSL_PLOG_IF_EVERY_N_IMPL(_##severity, condition, n) + ABSL_LOG_INTERNAL_PLOG_IF_EVERY_N_IMPL(_##severity, condition, n) #define ABSL_PLOG_IF_FIRST_N(severity, condition, n) \ - ABSL_PLOG_IF_FIRST_N_IMPL(_##severity, condition, n) + ABSL_LOG_INTERNAL_PLOG_IF_FIRST_N_IMPL(_##severity, condition, n) #define ABSL_PLOG_IF_EVERY_POW_2(severity, condition) \ - ABSL_PLOG_IF_EVERY_POW_2_IMPL(_##severity, condition) + ABSL_LOG_INTERNAL_PLOG_IF_EVERY_POW_2_IMPL(_##severity, condition) #define ABSL_PLOG_IF_EVERY_N_SEC(severity, condition, n_seconds) \ - ABSL_PLOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds) + ABSL_LOG_INTERNAL_PLOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds) #define ABSL_DLOG_IF_EVERY_N(severity, condition, n) \ - ABSL_DLOG_IF_EVERY_N_IMPL(_##severity, condition, n) + ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_IMPL(_##severity, condition, n) #define ABSL_DLOG_IF_FIRST_N(severity, condition, n) \ - ABSL_DLOG_IF_FIRST_N_IMPL(_##severity, condition, n) + ABSL_LOG_INTERNAL_DLOG_IF_FIRST_N_IMPL(_##severity, condition, n) #define ABSL_DLOG_IF_EVERY_POW_2(severity, condition) \ - ABSL_DLOG_IF_EVERY_POW_2_IMPL(_##severity, condition) + ABSL_LOG_INTERNAL_DLOG_IF_EVERY_POW_2_IMPL(_##severity, condition) #define ABSL_DLOG_IF_EVERY_N_SEC(severity, condition, n_seconds) \ - ABSL_DLOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds) + ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds) #endif // ABSL_LOG_ABSL_LOG_H_ diff --git a/absl/log/absl_log_basic_test.cc b/absl/log/absl_log_basic_test.cc index bc8a787d..3a4b83c1 100644 --- a/absl/log/absl_log_basic_test.cc +++ b/absl/log/absl_log_basic_test.cc @@ -18,4 +18,4 @@ #define ABSL_TEST_LOG ABSL_LOG #include "gtest/gtest.h" -#include "absl/log/log_basic_test_impl.h" +#include "absl/log/log_basic_test_impl.inc" diff --git a/absl/log/check.h b/absl/log/check.h index 33145a57..0a2f2e4e 100644 --- a/absl/log/check.h +++ b/absl/log/check.h @@ -54,7 +54,7 @@ // Might produce a message like: // // Check failed: !cheese.empty() Out of Cheese -#define CHECK(condition) ABSL_CHECK_IMPL((condition), #condition) +#define CHECK(condition) ABSL_LOG_INTERNAL_CHECK_IMPL((condition), #condition) // QCHECK() // @@ -62,7 +62,7 @@ // not run registered error handlers (as `QFATAL`). It is useful when the // problem is definitely unrelated to program flow, e.g. when validating user // input. -#define QCHECK(condition) ABSL_QCHECK_IMPL((condition), #condition) +#define QCHECK(condition) ABSL_LOG_INTERNAL_QCHECK_IMPL((condition), #condition) // PCHECK() // @@ -77,7 +77,7 @@ // Might produce a message like: // // Check failed: fd != -1 posix is difficult: No such file or directory [2] -#define PCHECK(condition) ABSL_PCHECK_IMPL((condition), #condition) +#define PCHECK(condition) ABSL_LOG_INTERNAL_PCHECK_IMPL((condition), #condition) // DCHECK() // @@ -85,7 +85,7 @@ // `DLOG`). Unlike with `CHECK` (but as with `assert`), it is not safe to rely // on evaluation of `condition`: when `NDEBUG` is enabled, DCHECK does not // evaluate the condition. -#define DCHECK(condition) ABSL_DCHECK_IMPL((condition), #condition) +#define DCHECK(condition) ABSL_LOG_INTERNAL_DCHECK_IMPL((condition), #condition) // `CHECK_EQ` and friends are syntactic sugar for `CHECK(x == y)` that // automatically output the expression being tested and the evaluated values on @@ -113,24 +113,42 @@ // // WARNING: Passing `NULL` as an argument to `CHECK_EQ` and similar macros does // not compile. Use `nullptr` instead. -#define CHECK_EQ(val1, val2) ABSL_CHECK_EQ_IMPL((val1), #val1, (val2), #val2) -#define CHECK_NE(val1, val2) ABSL_CHECK_NE_IMPL((val1), #val1, (val2), #val2) -#define CHECK_LE(val1, val2) ABSL_CHECK_LE_IMPL((val1), #val1, (val2), #val2) -#define CHECK_LT(val1, val2) ABSL_CHECK_LT_IMPL((val1), #val1, (val2), #val2) -#define CHECK_GE(val1, val2) ABSL_CHECK_GE_IMPL((val1), #val1, (val2), #val2) -#define CHECK_GT(val1, val2) ABSL_CHECK_GT_IMPL((val1), #val1, (val2), #val2) -#define QCHECK_EQ(val1, val2) ABSL_QCHECK_EQ_IMPL((val1), #val1, (val2), #val2) -#define QCHECK_NE(val1, val2) ABSL_QCHECK_NE_IMPL((val1), #val1, (val2), #val2) -#define QCHECK_LE(val1, val2) ABSL_QCHECK_LE_IMPL((val1), #val1, (val2), #val2) -#define QCHECK_LT(val1, val2) ABSL_QCHECK_LT_IMPL((val1), #val1, (val2), #val2) -#define QCHECK_GE(val1, val2) ABSL_QCHECK_GE_IMPL((val1), #val1, (val2), #val2) -#define QCHECK_GT(val1, val2) ABSL_QCHECK_GT_IMPL((val1), #val1, (val2), #val2) -#define DCHECK_EQ(val1, val2) ABSL_DCHECK_EQ_IMPL((val1), #val1, (val2), #val2) -#define DCHECK_NE(val1, val2) ABSL_DCHECK_NE_IMPL((val1), #val1, (val2), #val2) -#define DCHECK_LE(val1, val2) ABSL_DCHECK_LE_IMPL((val1), #val1, (val2), #val2) -#define DCHECK_LT(val1, val2) ABSL_DCHECK_LT_IMPL((val1), #val1, (val2), #val2) -#define DCHECK_GE(val1, val2) ABSL_DCHECK_GE_IMPL((val1), #val1, (val2), #val2) -#define DCHECK_GT(val1, val2) ABSL_DCHECK_GT_IMPL((val1), #val1, (val2), #val2) +#define CHECK_EQ(val1, val2) \ + ABSL_LOG_INTERNAL_CHECK_EQ_IMPL((val1), #val1, (val2), #val2) +#define CHECK_NE(val1, val2) \ + ABSL_LOG_INTERNAL_CHECK_NE_IMPL((val1), #val1, (val2), #val2) +#define CHECK_LE(val1, val2) \ + ABSL_LOG_INTERNAL_CHECK_LE_IMPL((val1), #val1, (val2), #val2) +#define CHECK_LT(val1, val2) \ + ABSL_LOG_INTERNAL_CHECK_LT_IMPL((val1), #val1, (val2), #val2) +#define CHECK_GE(val1, val2) \ + ABSL_LOG_INTERNAL_CHECK_GE_IMPL((val1), #val1, (val2), #val2) +#define CHECK_GT(val1, val2) \ + ABSL_LOG_INTERNAL_CHECK_GT_IMPL((val1), #val1, (val2), #val2) +#define QCHECK_EQ(val1, val2) \ + ABSL_LOG_INTERNAL_QCHECK_EQ_IMPL((val1), #val1, (val2), #val2) +#define QCHECK_NE(val1, val2) \ + ABSL_LOG_INTERNAL_QCHECK_NE_IMPL((val1), #val1, (val2), #val2) +#define QCHECK_LE(val1, val2) \ + ABSL_LOG_INTERNAL_QCHECK_LE_IMPL((val1), #val1, (val2), #val2) +#define QCHECK_LT(val1, val2) \ + ABSL_LOG_INTERNAL_QCHECK_LT_IMPL((val1), #val1, (val2), #val2) +#define QCHECK_GE(val1, val2) \ + ABSL_LOG_INTERNAL_QCHECK_GE_IMPL((val1), #val1, (val2), #val2) +#define QCHECK_GT(val1, val2) \ + ABSL_LOG_INTERNAL_QCHECK_GT_IMPL((val1), #val1, (val2), #val2) +#define DCHECK_EQ(val1, val2) \ + ABSL_LOG_INTERNAL_DCHECK_EQ_IMPL((val1), #val1, (val2), #val2) +#define DCHECK_NE(val1, val2) \ + ABSL_LOG_INTERNAL_DCHECK_NE_IMPL((val1), #val1, (val2), #val2) +#define DCHECK_LE(val1, val2) \ + ABSL_LOG_INTERNAL_DCHECK_LE_IMPL((val1), #val1, (val2), #val2) +#define DCHECK_LT(val1, val2) \ + ABSL_LOG_INTERNAL_DCHECK_LT_IMPL((val1), #val1, (val2), #val2) +#define DCHECK_GE(val1, val2) \ + ABSL_LOG_INTERNAL_DCHECK_GE_IMPL((val1), #val1, (val2), #val2) +#define DCHECK_GT(val1, val2) \ + ABSL_LOG_INTERNAL_DCHECK_GT_IMPL((val1), #val1, (val2), #val2) // `CHECK_OK` and friends validate that the provided `absl::Status` or // `absl::StatusOr<T>` is OK. If it isn't, they print a failure message that @@ -146,9 +164,9 @@ // Might produce a message like: // // Check failed: FunctionReturnsStatus(x, y, z) is OK (ABORTED: timeout) oops! -#define CHECK_OK(status) ABSL_CHECK_OK_IMPL((status), #status) -#define QCHECK_OK(status) ABSL_QCHECK_OK_IMPL((status), #status) -#define DCHECK_OK(status) ABSL_DCHECK_OK_IMPL((status), #status) +#define CHECK_OK(status) ABSL_LOG_INTERNAL_CHECK_OK_IMPL((status), #status) +#define QCHECK_OK(status) ABSL_LOG_INTERNAL_QCHECK_OK_IMPL((status), #status) +#define DCHECK_OK(status) ABSL_LOG_INTERNAL_DCHECK_OK_IMPL((status), #status) // `CHECK_STREQ` and friends provide `CHECK_EQ` functionality for C strings, // i.e., nul-terminated char arrays. The `CASE` versions are case-insensitive. @@ -163,21 +181,29 @@ // Example: // // CHECK_STREQ(Foo().c_str(), Bar().c_str()); -#define CHECK_STREQ(s1, s2) ABSL_CHECK_STREQ_IMPL((s1), #s1, (s2), #s2) -#define CHECK_STRNE(s1, s2) ABSL_CHECK_STRNE_IMPL((s1), #s1, (s2), #s2) -#define CHECK_STRCASEEQ(s1, s2) ABSL_CHECK_STRCASEEQ_IMPL((s1), #s1, (s2), #s2) -#define CHECK_STRCASENE(s1, s2) ABSL_CHECK_STRCASENE_IMPL((s1), #s1, (s2), #s2) -#define QCHECK_STREQ(s1, s2) ABSL_QCHECK_STREQ_IMPL((s1), #s1, (s2), #s2) -#define QCHECK_STRNE(s1, s2) ABSL_QCHECK_STRNE_IMPL((s1), #s1, (s2), #s2) +#define CHECK_STREQ(s1, s2) \ + ABSL_LOG_INTERNAL_CHECK_STREQ_IMPL((s1), #s1, (s2), #s2) +#define CHECK_STRNE(s1, s2) \ + ABSL_LOG_INTERNAL_CHECK_STRNE_IMPL((s1), #s1, (s2), #s2) +#define CHECK_STRCASEEQ(s1, s2) \ + ABSL_LOG_INTERNAL_CHECK_STRCASEEQ_IMPL((s1), #s1, (s2), #s2) +#define CHECK_STRCASENE(s1, s2) \ + ABSL_LOG_INTERNAL_CHECK_STRCASENE_IMPL((s1), #s1, (s2), #s2) +#define QCHECK_STREQ(s1, s2) \ + ABSL_LOG_INTERNAL_QCHECK_STREQ_IMPL((s1), #s1, (s2), #s2) +#define QCHECK_STRNE(s1, s2) \ + ABSL_LOG_INTERNAL_QCHECK_STRNE_IMPL((s1), #s1, (s2), #s2) #define QCHECK_STRCASEEQ(s1, s2) \ - ABSL_QCHECK_STRCASEEQ_IMPL((s1), #s1, (s2), #s2) + ABSL_LOG_INTERNAL_QCHECK_STRCASEEQ_IMPL((s1), #s1, (s2), #s2) #define QCHECK_STRCASENE(s1, s2) \ - ABSL_QCHECK_STRCASENE_IMPL((s1), #s1, (s2), #s2) -#define DCHECK_STREQ(s1, s2) ABSL_DCHECK_STREQ_IMPL((s1), #s1, (s2), #s2) -#define DCHECK_STRNE(s1, s2) ABSL_DCHECK_STRNE_IMPL((s1), #s1, (s2), #s2) + ABSL_LOG_INTERNAL_QCHECK_STRCASENE_IMPL((s1), #s1, (s2), #s2) +#define DCHECK_STREQ(s1, s2) \ + ABSL_LOG_INTERNAL_DCHECK_STREQ_IMPL((s1), #s1, (s2), #s2) +#define DCHECK_STRNE(s1, s2) \ + ABSL_LOG_INTERNAL_DCHECK_STRNE_IMPL((s1), #s1, (s2), #s2) #define DCHECK_STRCASEEQ(s1, s2) \ - ABSL_DCHECK_STRCASEEQ_IMPL((s1), #s1, (s2), #s2) + ABSL_LOG_INTERNAL_DCHECK_STRCASEEQ_IMPL((s1), #s1, (s2), #s2) #define DCHECK_STRCASENE(s1, s2) \ - ABSL_DCHECK_STRCASENE_IMPL((s1), #s1, (s2), #s2) + ABSL_LOG_INTERNAL_DCHECK_STRCASENE_IMPL((s1), #s1, (s2), #s2) #endif // ABSL_LOG_CHECK_H_ diff --git a/absl/log/check_test.cc b/absl/log/check_test.cc index f44a686e..ef415bd4 100644 --- a/absl/log/check_test.cc +++ b/absl/log/check_test.cc @@ -55,4 +55,4 @@ #define ABSL_TEST_QCHECK_STRCASENE QCHECK_STRCASENE #include "gtest/gtest.h" -#include "absl/log/check_test_impl.h" +#include "absl/log/check_test_impl.inc" diff --git a/absl/log/check_test_impl.h b/absl/log/check_test_impl.inc index d5c0aee4..d5c0aee4 100644 --- a/absl/log/check_test_impl.h +++ b/absl/log/check_test_impl.inc diff --git a/absl/log/internal/check_impl.h b/absl/log/internal/check_impl.h index c9c28e3e..00f25f80 100644 --- a/absl/log/internal/check_impl.h +++ b/absl/log/internal/check_impl.h @@ -22,128 +22,128 @@ #include "absl/log/internal/strip.h" // CHECK -#define ABSL_CHECK_IMPL(condition, condition_text) \ +#define ABSL_LOG_INTERNAL_CHECK_IMPL(condition, condition_text) \ ABSL_LOG_INTERNAL_CONDITION_FATAL(STATELESS, \ ABSL_PREDICT_FALSE(!(condition))) \ ABSL_LOG_INTERNAL_CHECK(condition_text).InternalStream() -#define ABSL_QCHECK_IMPL(condition, condition_text) \ +#define ABSL_LOG_INTERNAL_QCHECK_IMPL(condition, condition_text) \ ABSL_LOG_INTERNAL_CONDITION_QFATAL(STATELESS, \ ABSL_PREDICT_FALSE(!(condition))) \ ABSL_LOG_INTERNAL_QCHECK(condition_text).InternalStream() -#define ABSL_PCHECK_IMPL(condition, condition_text) \ - ABSL_CHECK_IMPL(condition, condition_text).WithPerror() +#define ABSL_LOG_INTERNAL_PCHECK_IMPL(condition, condition_text) \ + ABSL_LOG_INTERNAL_CHECK_IMPL(condition, condition_text).WithPerror() #ifndef NDEBUG -#define ABSL_DCHECK_IMPL(condition, condition_text) \ - ABSL_CHECK_IMPL(condition, condition_text) +#define ABSL_LOG_INTERNAL_DCHECK_IMPL(condition, condition_text) \ + ABSL_LOG_INTERNAL_CHECK_IMPL(condition, condition_text) #else -#define ABSL_DCHECK_IMPL(condition, condition_text) \ - ABSL_CHECK_IMPL(true || (condition), "true") +#define ABSL_LOG_INTERNAL_DCHECK_IMPL(condition, condition_text) \ + ABSL_LOG_INTERNAL_CHECK_IMPL(true || (condition), "true") #endif // CHECK_EQ -#define ABSL_CHECK_EQ_IMPL(val1, val1_text, val2, val2_text) \ +#define ABSL_LOG_INTERNAL_CHECK_EQ_IMPL(val1, val1_text, val2, val2_text) \ ABSL_LOG_INTERNAL_CHECK_OP(Check_EQ, ==, val1, val1_text, val2, val2_text) -#define ABSL_CHECK_NE_IMPL(val1, val1_text, val2, val2_text) \ +#define ABSL_LOG_INTERNAL_CHECK_NE_IMPL(val1, val1_text, val2, val2_text) \ ABSL_LOG_INTERNAL_CHECK_OP(Check_NE, !=, val1, val1_text, val2, val2_text) -#define ABSL_CHECK_LE_IMPL(val1, val1_text, val2, val2_text) \ +#define ABSL_LOG_INTERNAL_CHECK_LE_IMPL(val1, val1_text, val2, val2_text) \ ABSL_LOG_INTERNAL_CHECK_OP(Check_LE, <=, val1, val1_text, val2, val2_text) -#define ABSL_CHECK_LT_IMPL(val1, val1_text, val2, val2_text) \ +#define ABSL_LOG_INTERNAL_CHECK_LT_IMPL(val1, val1_text, val2, val2_text) \ ABSL_LOG_INTERNAL_CHECK_OP(Check_LT, <, val1, val1_text, val2, val2_text) -#define ABSL_CHECK_GE_IMPL(val1, val1_text, val2, val2_text) \ +#define ABSL_LOG_INTERNAL_CHECK_GE_IMPL(val1, val1_text, val2, val2_text) \ ABSL_LOG_INTERNAL_CHECK_OP(Check_GE, >=, val1, val1_text, val2, val2_text) -#define ABSL_CHECK_GT_IMPL(val1, val1_text, val2, val2_text) \ +#define ABSL_LOG_INTERNAL_CHECK_GT_IMPL(val1, val1_text, val2, val2_text) \ ABSL_LOG_INTERNAL_CHECK_OP(Check_GT, >, val1, val1_text, val2, val2_text) -#define ABSL_QCHECK_EQ_IMPL(val1, val1_text, val2, val2_text) \ +#define ABSL_LOG_INTERNAL_QCHECK_EQ_IMPL(val1, val1_text, val2, val2_text) \ ABSL_LOG_INTERNAL_QCHECK_OP(Check_EQ, ==, val1, val1_text, val2, val2_text) -#define ABSL_QCHECK_NE_IMPL(val1, val1_text, val2, val2_text) \ +#define ABSL_LOG_INTERNAL_QCHECK_NE_IMPL(val1, val1_text, val2, val2_text) \ ABSL_LOG_INTERNAL_QCHECK_OP(Check_NE, !=, val1, val1_text, val2, val2_text) -#define ABSL_QCHECK_LE_IMPL(val1, val1_text, val2, val2_text) \ +#define ABSL_LOG_INTERNAL_QCHECK_LE_IMPL(val1, val1_text, val2, val2_text) \ ABSL_LOG_INTERNAL_QCHECK_OP(Check_LE, <=, val1, val1_text, val2, val2_text) -#define ABSL_QCHECK_LT_IMPL(val1, val1_text, val2, val2_text) \ +#define ABSL_LOG_INTERNAL_QCHECK_LT_IMPL(val1, val1_text, val2, val2_text) \ ABSL_LOG_INTERNAL_QCHECK_OP(Check_LT, <, val1, val1_text, val2, val2_text) -#define ABSL_QCHECK_GE_IMPL(val1, val1_text, val2, val2_text) \ +#define ABSL_LOG_INTERNAL_QCHECK_GE_IMPL(val1, val1_text, val2, val2_text) \ ABSL_LOG_INTERNAL_QCHECK_OP(Check_GE, >=, val1, val1_text, val2, val2_text) -#define ABSL_QCHECK_GT_IMPL(val1, val1_text, val2, val2_text) \ +#define ABSL_LOG_INTERNAL_QCHECK_GT_IMPL(val1, val1_text, val2, val2_text) \ ABSL_LOG_INTERNAL_QCHECK_OP(Check_GT, >, val1, val1_text, val2, val2_text) #ifndef NDEBUG -#define ABSL_DCHECK_EQ_IMPL(val1, val1_text, val2, val2_text) \ - ABSL_CHECK_EQ_IMPL(val1, val1_text, val2, val2_text) -#define ABSL_DCHECK_NE_IMPL(val1, val1_text, val2, val2_text) \ - ABSL_CHECK_NE_IMPL(val1, val1_text, val2, val2_text) -#define ABSL_DCHECK_LE_IMPL(val1, val1_text, val2, val2_text) \ - ABSL_CHECK_LE_IMPL(val1, val1_text, val2, val2_text) -#define ABSL_DCHECK_LT_IMPL(val1, val1_text, val2, val2_text) \ - ABSL_CHECK_LT_IMPL(val1, val1_text, val2, val2_text) -#define ABSL_DCHECK_GE_IMPL(val1, val1_text, val2, val2_text) \ - ABSL_CHECK_GE_IMPL(val1, val1_text, val2, val2_text) -#define ABSL_DCHECK_GT_IMPL(val1, val1_text, val2, val2_text) \ - ABSL_CHECK_GT_IMPL(val1, val1_text, val2, val2_text) +#define ABSL_LOG_INTERNAL_DCHECK_EQ_IMPL(val1, val1_text, val2, val2_text) \ + ABSL_LOG_INTERNAL_CHECK_EQ_IMPL(val1, val1_text, val2, val2_text) +#define ABSL_LOG_INTERNAL_DCHECK_NE_IMPL(val1, val1_text, val2, val2_text) \ + ABSL_LOG_INTERNAL_CHECK_NE_IMPL(val1, val1_text, val2, val2_text) +#define ABSL_LOG_INTERNAL_DCHECK_LE_IMPL(val1, val1_text, val2, val2_text) \ + ABSL_LOG_INTERNAL_CHECK_LE_IMPL(val1, val1_text, val2, val2_text) +#define ABSL_LOG_INTERNAL_DCHECK_LT_IMPL(val1, val1_text, val2, val2_text) \ + ABSL_LOG_INTERNAL_CHECK_LT_IMPL(val1, val1_text, val2, val2_text) +#define ABSL_LOG_INTERNAL_DCHECK_GE_IMPL(val1, val1_text, val2, val2_text) \ + ABSL_LOG_INTERNAL_CHECK_GE_IMPL(val1, val1_text, val2, val2_text) +#define ABSL_LOG_INTERNAL_DCHECK_GT_IMPL(val1, val1_text, val2, val2_text) \ + ABSL_LOG_INTERNAL_CHECK_GT_IMPL(val1, val1_text, val2, val2_text) #else // ndef NDEBUG -#define ABSL_DCHECK_EQ_IMPL(val1, val1_text, val2, val2_text) \ +#define ABSL_LOG_INTERNAL_DCHECK_EQ_IMPL(val1, val1_text, val2, val2_text) \ ABSL_LOG_INTERNAL_DCHECK_NOP(val1, val2) -#define ABSL_DCHECK_NE_IMPL(val1, val1_text, val2, val2_text) \ +#define ABSL_LOG_INTERNAL_DCHECK_NE_IMPL(val1, val1_text, val2, val2_text) \ ABSL_LOG_INTERNAL_DCHECK_NOP(val1, val2) -#define ABSL_DCHECK_LE_IMPL(val1, val1_text, val2, val2_text) \ +#define ABSL_LOG_INTERNAL_DCHECK_LE_IMPL(val1, val1_text, val2, val2_text) \ ABSL_LOG_INTERNAL_DCHECK_NOP(val1, val2) -#define ABSL_DCHECK_LT_IMPL(val1, val1_text, val2, val2_text) \ +#define ABSL_LOG_INTERNAL_DCHECK_LT_IMPL(val1, val1_text, val2, val2_text) \ ABSL_LOG_INTERNAL_DCHECK_NOP(val1, val2) -#define ABSL_DCHECK_GE_IMPL(val1, val1_text, val2, val2_text) \ +#define ABSL_LOG_INTERNAL_DCHECK_GE_IMPL(val1, val1_text, val2, val2_text) \ ABSL_LOG_INTERNAL_DCHECK_NOP(val1, val2) -#define ABSL_DCHECK_GT_IMPL(val1, val1_text, val2, val2_text) \ +#define ABSL_LOG_INTERNAL_DCHECK_GT_IMPL(val1, val1_text, val2, val2_text) \ ABSL_LOG_INTERNAL_DCHECK_NOP(val1, val2) #endif // def NDEBUG // CHECK_OK -#define ABSL_CHECK_OK_IMPL(status, status_text) \ +#define ABSL_LOG_INTERNAL_CHECK_OK_IMPL(status, status_text) \ ABSL_LOG_INTERNAL_CHECK_OK(status, status_text) -#define ABSL_QCHECK_OK_IMPL(status, status_text) \ +#define ABSL_LOG_INTERNAL_QCHECK_OK_IMPL(status, status_text) \ ABSL_LOG_INTERNAL_QCHECK_OK(status, status_text) #ifndef NDEBUG -#define ABSL_DCHECK_OK_IMPL(status, status_text) \ +#define ABSL_LOG_INTERNAL_DCHECK_OK_IMPL(status, status_text) \ ABSL_LOG_INTERNAL_CHECK_OK(status, status_text) #else -#define ABSL_DCHECK_OK_IMPL(status, status_text) \ +#define ABSL_LOG_INTERNAL_DCHECK_OK_IMPL(status, status_text) \ ABSL_LOG_INTERNAL_DCHECK_NOP(status, nullptr) #endif // CHECK_STREQ -#define ABSL_CHECK_STREQ_IMPL(s1, s1_text, s2, s2_text) \ +#define ABSL_LOG_INTERNAL_CHECK_STREQ_IMPL(s1, s1_text, s2, s2_text) \ ABSL_LOG_INTERNAL_CHECK_STROP(strcmp, ==, true, s1, s1_text, s2, s2_text) -#define ABSL_CHECK_STRNE_IMPL(s1, s1_text, s2, s2_text) \ +#define ABSL_LOG_INTERNAL_CHECK_STRNE_IMPL(s1, s1_text, s2, s2_text) \ ABSL_LOG_INTERNAL_CHECK_STROP(strcmp, !=, false, s1, s1_text, s2, s2_text) -#define ABSL_CHECK_STRCASEEQ_IMPL(s1, s1_text, s2, s2_text) \ +#define ABSL_LOG_INTERNAL_CHECK_STRCASEEQ_IMPL(s1, s1_text, s2, s2_text) \ ABSL_LOG_INTERNAL_CHECK_STROP(strcasecmp, ==, true, s1, s1_text, s2, s2_text) -#define ABSL_CHECK_STRCASENE_IMPL(s1, s1_text, s2, s2_text) \ +#define ABSL_LOG_INTERNAL_CHECK_STRCASENE_IMPL(s1, s1_text, s2, s2_text) \ ABSL_LOG_INTERNAL_CHECK_STROP(strcasecmp, !=, false, s1, s1_text, s2, s2_text) -#define ABSL_QCHECK_STREQ_IMPL(s1, s1_text, s2, s2_text) \ +#define ABSL_LOG_INTERNAL_QCHECK_STREQ_IMPL(s1, s1_text, s2, s2_text) \ ABSL_LOG_INTERNAL_QCHECK_STROP(strcmp, ==, true, s1, s1_text, s2, s2_text) -#define ABSL_QCHECK_STRNE_IMPL(s1, s1_text, s2, s2_text) \ +#define ABSL_LOG_INTERNAL_QCHECK_STRNE_IMPL(s1, s1_text, s2, s2_text) \ ABSL_LOG_INTERNAL_QCHECK_STROP(strcmp, !=, false, s1, s1_text, s2, s2_text) -#define ABSL_QCHECK_STRCASEEQ_IMPL(s1, s1_text, s2, s2_text) \ +#define ABSL_LOG_INTERNAL_QCHECK_STRCASEEQ_IMPL(s1, s1_text, s2, s2_text) \ ABSL_LOG_INTERNAL_QCHECK_STROP(strcasecmp, ==, true, s1, s1_text, s2, s2_text) -#define ABSL_QCHECK_STRCASENE_IMPL(s1, s1_text, s2, s2_text) \ - ABSL_LOG_INTERNAL_QCHECK_STROP(strcasecmp, !=, false, s1, s1_text, s2, \ +#define ABSL_LOG_INTERNAL_QCHECK_STRCASENE_IMPL(s1, s1_text, s2, s2_text) \ + ABSL_LOG_INTERNAL_QCHECK_STROP(strcasecmp, !=, false, s1, s1_text, s2, \ s2_text) #ifndef NDEBUG -#define ABSL_DCHECK_STREQ_IMPL(s1, s1_text, s2, s2_text) \ - ABSL_CHECK_STREQ_IMPL(s1, s1_text, s2, s2_text) -#define ABSL_DCHECK_STRCASEEQ_IMPL(s1, s1_text, s2, s2_text) \ - ABSL_CHECK_STRCASEEQ_IMPL(s1, s1_text, s2, s2_text) -#define ABSL_DCHECK_STRNE_IMPL(s1, s1_text, s2, s2_text) \ - ABSL_CHECK_STRNE_IMPL(s1, s1_text, s2, s2_text) -#define ABSL_DCHECK_STRCASENE_IMPL(s1, s1_text, s2, s2_text) \ - ABSL_CHECK_STRCASENE_IMPL(s1, s1_text, s2, s2_text) +#define ABSL_LOG_INTERNAL_DCHECK_STREQ_IMPL(s1, s1_text, s2, s2_text) \ + ABSL_LOG_INTERNAL_CHECK_STREQ_IMPL(s1, s1_text, s2, s2_text) +#define ABSL_LOG_INTERNAL_DCHECK_STRCASEEQ_IMPL(s1, s1_text, s2, s2_text) \ + ABSL_LOG_INTERNAL_CHECK_STRCASEEQ_IMPL(s1, s1_text, s2, s2_text) +#define ABSL_LOG_INTERNAL_DCHECK_STRNE_IMPL(s1, s1_text, s2, s2_text) \ + ABSL_LOG_INTERNAL_CHECK_STRNE_IMPL(s1, s1_text, s2, s2_text) +#define ABSL_LOG_INTERNAL_DCHECK_STRCASENE_IMPL(s1, s1_text, s2, s2_text) \ + ABSL_LOG_INTERNAL_CHECK_STRCASENE_IMPL(s1, s1_text, s2, s2_text) #else // ndef NDEBUG -#define ABSL_DCHECK_STREQ_IMPL(s1, s1_text, s2, s2_text) \ +#define ABSL_LOG_INTERNAL_DCHECK_STREQ_IMPL(s1, s1_text, s2, s2_text) \ ABSL_LOG_INTERNAL_DCHECK_NOP(s1, s2) -#define ABSL_DCHECK_STRCASEEQ_IMPL(s1, s1_text, s2, s2_text) \ +#define ABSL_LOG_INTERNAL_DCHECK_STRCASEEQ_IMPL(s1, s1_text, s2, s2_text) \ ABSL_LOG_INTERNAL_DCHECK_NOP(s1, s2) -#define ABSL_DCHECK_STRNE_IMPL(s1, s1_text, s2, s2_text) \ +#define ABSL_LOG_INTERNAL_DCHECK_STRNE_IMPL(s1, s1_text, s2, s2_text) \ ABSL_LOG_INTERNAL_DCHECK_NOP(s1, s2) -#define ABSL_DCHECK_STRCASENE_IMPL(s1, s1_text, s2, s2_text) \ +#define ABSL_LOG_INTERNAL_DCHECK_STRCASENE_IMPL(s1, s1_text, s2, s2_text) \ ABSL_LOG_INTERNAL_DCHECK_NOP(s1, s2) #endif // def NDEBUG diff --git a/absl/log/internal/log_impl.h b/absl/log/internal/log_impl.h index 82b5ed84..9326780d 100644 --- a/absl/log/internal/log_impl.h +++ b/absl/log/internal/log_impl.h @@ -20,190 +20,194 @@ #include "absl/log/internal/strip.h" // ABSL_LOG() -#define ABSL_LOG_IMPL(severity) \ +#define ABSL_LOG_INTERNAL_LOG_IMPL(severity) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, true) \ ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() // ABSL_PLOG() -#define ABSL_PLOG_IMPL(severity) \ +#define ABSL_LOG_INTERNAL_PLOG_IMPL(severity) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, true) \ ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() \ .WithPerror() // ABSL_DLOG() #ifndef NDEBUG -#define ABSL_DLOG_IMPL(severity) \ +#define ABSL_LOG_INTERNAL_DLOG_IMPL(severity) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, true) \ ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() #else -#define ABSL_DLOG_IMPL(severity) \ +#define ABSL_LOG_INTERNAL_DLOG_IMPL(severity) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, false) \ ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() #endif -#define ABSL_LOG_IF_IMPL(severity, condition) \ +#define ABSL_LOG_INTERNAL_LOG_IF_IMPL(severity, condition) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, condition) \ ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() -#define ABSL_PLOG_IF_IMPL(severity, condition) \ +#define ABSL_LOG_INTERNAL_PLOG_IF_IMPL(severity, condition) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, condition) \ ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() \ .WithPerror() #ifndef NDEBUG -#define ABSL_DLOG_IF_IMPL(severity, condition) \ +#define ABSL_LOG_INTERNAL_DLOG_IF_IMPL(severity, condition) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, condition) \ ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() #else -#define ABSL_DLOG_IF_IMPL(severity, condition) \ +#define ABSL_LOG_INTERNAL_DLOG_IF_IMPL(severity, condition) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATELESS, false && (condition)) \ ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() #endif // ABSL_LOG_EVERY_N -#define ABSL_LOG_EVERY_N_IMPL(severity, n) \ +#define ABSL_LOG_INTERNAL_LOG_EVERY_N_IMPL(severity, n) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(EveryN, n) \ ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() // ABSL_LOG_FIRST_N -#define ABSL_LOG_FIRST_N_IMPL(severity, n) \ +#define ABSL_LOG_INTERNAL_LOG_FIRST_N_IMPL(severity, n) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(FirstN, n) \ ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() // ABSL_LOG_EVERY_POW_2 -#define ABSL_LOG_EVERY_POW_2_IMPL(severity) \ +#define ABSL_LOG_INTERNAL_LOG_EVERY_POW_2_IMPL(severity) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(EveryPow2) \ ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() // ABSL_LOG_EVERY_N_SEC -#define ABSL_LOG_EVERY_N_SEC_IMPL(severity, n_seconds) \ +#define ABSL_LOG_INTERNAL_LOG_EVERY_N_SEC_IMPL(severity, n_seconds) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(EveryNSec, n_seconds) \ ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() -#define ABSL_PLOG_EVERY_N_IMPL(severity, n) \ +#define ABSL_LOG_INTERNAL_PLOG_EVERY_N_IMPL(severity, n) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(EveryN, n) \ ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() \ .WithPerror() -#define ABSL_PLOG_FIRST_N_IMPL(severity, n) \ +#define ABSL_LOG_INTERNAL_PLOG_FIRST_N_IMPL(severity, n) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(FirstN, n) \ ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() \ .WithPerror() -#define ABSL_PLOG_EVERY_POW_2_IMPL(severity) \ +#define ABSL_LOG_INTERNAL_PLOG_EVERY_POW_2_IMPL(severity) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(EveryPow2) \ ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() \ .WithPerror() -#define ABSL_PLOG_EVERY_N_SEC_IMPL(severity, n_seconds) \ +#define ABSL_LOG_INTERNAL_PLOG_EVERY_N_SEC_IMPL(severity, n_seconds) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, true)(EveryNSec, n_seconds) \ ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() \ .WithPerror() #ifndef NDEBUG -#define ABSL_DLOG_EVERY_N_IMPL(severity, n) \ - ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, true) \ +#define ABSL_LOG_INTERNAL_DLOG_EVERY_N_IMPL(severity, n) \ + ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, true) \ (EveryN, n) ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() -#define ABSL_DLOG_FIRST_N_IMPL(severity, n) \ - ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, true) \ +#define ABSL_LOG_INTERNAL_DLOG_FIRST_N_IMPL(severity, n) \ + ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, true) \ (FirstN, n) ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() -#define ABSL_DLOG_EVERY_POW_2_IMPL(severity) \ - ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, true) \ +#define ABSL_LOG_INTERNAL_DLOG_EVERY_POW_2_IMPL(severity) \ + ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, true) \ (EveryPow2) ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() -#define ABSL_DLOG_EVERY_N_SEC_IMPL(severity, n_seconds) \ - ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, true) \ +#define ABSL_LOG_INTERNAL_DLOG_EVERY_N_SEC_IMPL(severity, n_seconds) \ + ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, true) \ (EveryNSec, n_seconds) ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() #else // def NDEBUG -#define ABSL_DLOG_EVERY_N_IMPL(severity, n) \ - ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, false) \ +#define ABSL_LOG_INTERNAL_DLOG_EVERY_N_IMPL(severity, n) \ + ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, false) \ (EveryN, n) ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() -#define ABSL_DLOG_FIRST_N_IMPL(severity, n) \ - ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, false) \ +#define ABSL_LOG_INTERNAL_DLOG_FIRST_N_IMPL(severity, n) \ + ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, false) \ (FirstN, n) ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() -#define ABSL_DLOG_EVERY_POW_2_IMPL(severity) \ - ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, false) \ +#define ABSL_LOG_INTERNAL_DLOG_EVERY_POW_2_IMPL(severity) \ + ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, false) \ (EveryPow2) ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() -#define ABSL_DLOG_EVERY_N_SEC_IMPL(severity, n_seconds) \ - ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, false) \ +#define ABSL_LOG_INTERNAL_DLOG_EVERY_N_SEC_IMPL(severity, n_seconds) \ + ABSL_LOG_INTERNAL_CONDITION_INFO(STATEFUL, false) \ (EveryNSec, n_seconds) ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() #endif // def NDEBUG -#define ABSL_LOG_IF_EVERY_N_IMPL(severity, condition, n) \ +#define ABSL_LOG_INTERNAL_LOG_IF_EVERY_N_IMPL(severity, condition, n) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryN, n) \ ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() -#define ABSL_LOG_IF_FIRST_N_IMPL(severity, condition, n) \ +#define ABSL_LOG_INTERNAL_LOG_IF_FIRST_N_IMPL(severity, condition, n) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(FirstN, n) \ ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() -#define ABSL_LOG_IF_EVERY_POW_2_IMPL(severity, condition) \ +#define ABSL_LOG_INTERNAL_LOG_IF_EVERY_POW_2_IMPL(severity, condition) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryPow2) \ ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() -#define ABSL_LOG_IF_EVERY_N_SEC_IMPL(severity, condition, n_seconds) \ +#define ABSL_LOG_INTERNAL_LOG_IF_EVERY_N_SEC_IMPL(severity, condition, \ + n_seconds) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryNSec, \ n_seconds) \ ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() -#define ABSL_PLOG_IF_EVERY_N_IMPL(severity, condition, n) \ +#define ABSL_LOG_INTERNAL_PLOG_IF_EVERY_N_IMPL(severity, condition, n) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryN, n) \ ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() \ .WithPerror() -#define ABSL_PLOG_IF_FIRST_N_IMPL(severity, condition, n) \ +#define ABSL_LOG_INTERNAL_PLOG_IF_FIRST_N_IMPL(severity, condition, n) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(FirstN, n) \ ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() \ .WithPerror() -#define ABSL_PLOG_IF_EVERY_POW_2_IMPL(severity, condition) \ +#define ABSL_LOG_INTERNAL_PLOG_IF_EVERY_POW_2_IMPL(severity, condition) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryPow2) \ ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() \ .WithPerror() -#define ABSL_PLOG_IF_EVERY_N_SEC_IMPL(severity, condition, n_seconds) \ +#define ABSL_LOG_INTERNAL_PLOG_IF_EVERY_N_SEC_IMPL(severity, condition, \ + n_seconds) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryNSec, \ n_seconds) \ ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() \ .WithPerror() #ifndef NDEBUG -#define ABSL_DLOG_IF_EVERY_N_IMPL(severity, condition, n) \ +#define ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_IMPL(severity, condition, n) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryN, n) \ ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() -#define ABSL_DLOG_IF_FIRST_N_IMPL(severity, condition, n) \ +#define ABSL_LOG_INTERNAL_DLOG_IF_FIRST_N_IMPL(severity, condition, n) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(FirstN, n) \ ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() -#define ABSL_DLOG_IF_EVERY_POW_2_IMPL(severity, condition) \ +#define ABSL_LOG_INTERNAL_DLOG_IF_EVERY_POW_2_IMPL(severity, condition) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryPow2) \ ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() -#define ABSL_DLOG_IF_EVERY_N_SEC_IMPL(severity, condition, n_seconds) \ +#define ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_SEC_IMPL(severity, condition, \ + n_seconds) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, condition)(EveryNSec, \ n_seconds) \ ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() #else // def NDEBUG -#define ABSL_DLOG_IF_EVERY_N_IMPL(severity, condition, n) \ +#define ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_IMPL(severity, condition, n) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, false && (condition))( \ EveryN, n) ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() -#define ABSL_DLOG_IF_FIRST_N_IMPL(severity, condition, n) \ +#define ABSL_LOG_INTERNAL_DLOG_IF_FIRST_N_IMPL(severity, condition, n) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, false && (condition))( \ FirstN, n) ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() -#define ABSL_DLOG_IF_EVERY_POW_2_IMPL(severity, condition) \ +#define ABSL_LOG_INTERNAL_DLOG_IF_EVERY_POW_2_IMPL(severity, condition) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, false && (condition))( \ EveryPow2) ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() -#define ABSL_DLOG_IF_EVERY_N_SEC_IMPL(severity, condition, n_seconds) \ +#define ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_SEC_IMPL(severity, condition, \ + n_seconds) \ ABSL_LOG_INTERNAL_CONDITION##severity(STATEFUL, false && (condition))( \ EveryNSec, n_seconds) \ ABSL_LOGGING_INTERNAL_LOG##severity.InternalStream() diff --git a/absl/log/log.h b/absl/log/log.h index e060a0b6..602b5acf 100644 --- a/absl/log/log.h +++ b/absl/log/log.h @@ -196,29 +196,32 @@ // Example: // // LOG(INFO) << "Found " << num_cookies << " cookies"; -#define LOG(severity) ABSL_LOG_IMPL(_##severity) +#define LOG(severity) ABSL_LOG_INTERNAL_LOG_IMPL(_##severity) // PLOG() // // `PLOG` behaves like `LOG` except that a description of the current state of // `errno` is appended to the streamed message. -#define PLOG(severity) ABSL_PLOG_IMPL(_##severity) +#define PLOG(severity) ABSL_LOG_INTERNAL_PLOG_IMPL(_##severity) // DLOG() // // `DLOG` behaves like `LOG` in debug mode (i.e. `#ifndef NDEBUG`). Otherwise // it compiles away and does nothing. Note that `DLOG(FATAL)` does not // terminate the program if `NDEBUG` is defined. -#define DLOG(severity) ABSL_DLOG_IMPL(_##severity) +#define DLOG(severity) ABSL_LOG_INTERNAL_DLOG_IMPL(_##severity) // `LOG_IF` and friends add a second argument which specifies a condition. If // the condition is false, nothing is logged. // Example: // // LOG_IF(INFO, num_cookies > 10) << "Got lots of cookies"; -#define LOG_IF(severity, condition) ABSL_LOG_IF_IMPL(_##severity, condition) -#define PLOG_IF(severity, condition) ABSL_PLOG_IF_IMPL(_##severity, condition) -#define DLOG_IF(severity, condition) ABSL_DLOG_IF_IMPL(_##severity, condition) +#define LOG_IF(severity, condition) \ + ABSL_LOG_INTERNAL_LOG_IF_IMPL(_##severity, condition) +#define PLOG_IF(severity, condition) \ + ABSL_LOG_INTERNAL_PLOG_IF_IMPL(_##severity, condition) +#define DLOG_IF(severity, condition) \ + ABSL_LOG_INTERNAL_DLOG_IF_IMPL(_##severity, condition) // LOG_EVERY_N // @@ -231,21 +234,24 @@ // // LOG_EVERY_N(WARNING, 1000) << "Got a packet with a bad CRC (" << COUNTER // << " total)"; -#define LOG_EVERY_N(severity, n) ABSL_LOG_EVERY_N_IMPL(_##severity, n) +#define LOG_EVERY_N(severity, n) \ + ABSL_LOG_INTERNAL_LOG_EVERY_N_IMPL(_##severity, n) // LOG_FIRST_N // // `LOG_FIRST_N` behaves like `LOG_EVERY_N` except that the specified message is // logged when the counter's value is less than `n`. `LOG_FIRST_N` is // thread-safe. -#define LOG_FIRST_N(severity, n) ABSL_LOG_FIRST_N_IMPL(_##severity, n) +#define LOG_FIRST_N(severity, n) \ + ABSL_LOG_INTERNAL_LOG_FIRST_N_IMPL(_##severity, n) // LOG_EVERY_POW_2 // // `LOG_EVERY_POW_2` behaves like `LOG_EVERY_N` except that the specified // message is logged when the counter's value is a power of 2. // `LOG_EVERY_POW_2` is thread-safe. -#define LOG_EVERY_POW_2(severity) ABSL_LOG_EVERY_POW_2_IMPL(_##severity) +#define LOG_EVERY_POW_2(severity) \ + ABSL_LOG_INTERNAL_LOG_EVERY_POW_2_IMPL(_##severity) // LOG_EVERY_N_SEC // @@ -257,19 +263,25 @@ // // LOG_EVERY_N_SEC(INFO, 2.5) << "Got " << COUNTER << " cookies so far"; #define LOG_EVERY_N_SEC(severity, n_seconds) \ - ABSL_LOG_EVERY_N_SEC_IMPL(_##severity, n_seconds) + ABSL_LOG_INTERNAL_LOG_EVERY_N_SEC_IMPL(_##severity, n_seconds) -#define PLOG_EVERY_N(severity, n) ABSL_PLOG_EVERY_N_IMPL(_##severity, n) -#define PLOG_FIRST_N(severity, n) ABSL_PLOG_FIRST_N_IMPL(_##severity, n) -#define PLOG_EVERY_POW_2(severity) ABSL_PLOG_EVERY_POW_2_IMPL(_##severity) +#define PLOG_EVERY_N(severity, n) \ + ABSL_LOG_INTERNAL_PLOG_EVERY_N_IMPL(_##severity, n) +#define PLOG_FIRST_N(severity, n) \ + ABSL_LOG_INTERNAL_PLOG_FIRST_N_IMPL(_##severity, n) +#define PLOG_EVERY_POW_2(severity) \ + ABSL_LOG_INTERNAL_PLOG_EVERY_POW_2_IMPL(_##severity) #define PLOG_EVERY_N_SEC(severity, n_seconds) \ - ABSL_PLOG_EVERY_N_SEC_IMPL(_##severity, n_seconds) + ABSL_LOG_INTERNAL_PLOG_EVERY_N_SEC_IMPL(_##severity, n_seconds) -#define DLOG_EVERY_N(severity, n) ABSL_DLOG_EVERY_N_IMPL(_##severity, n) -#define DLOG_FIRST_N(severity, n) ABSL_DLOG_FIRST_N_IMPL(_##severity, n) -#define DLOG_EVERY_POW_2(severity) ABSL_DLOG_EVERY_POW_2_IMPL(_##severity) +#define DLOG_EVERY_N(severity, n) \ + ABSL_LOG_INTERNAL_DLOG_EVERY_N_IMPL(_##severity, n) +#define DLOG_FIRST_N(severity, n) \ + ABSL_LOG_INTERNAL_DLOG_FIRST_N_IMPL(_##severity, n) +#define DLOG_EVERY_POW_2(severity) \ + ABSL_LOG_INTERNAL_DLOG_EVERY_POW_2_IMPL(_##severity) #define DLOG_EVERY_N_SEC(severity, n_seconds) \ - ABSL_DLOG_EVERY_N_SEC_IMPL(_##severity, n_seconds) + ABSL_LOG_INTERNAL_DLOG_EVERY_N_SEC_IMPL(_##severity, n_seconds) // `LOG_IF_EVERY_N` and friends behave as the corresponding `LOG_EVERY_N` // but neither increment a counter nor log a message if condition is false (as @@ -279,30 +291,30 @@ // LOG_IF_EVERY_N(INFO, (size > 1024), 10) << "Got the " << COUNTER // << "th big cookie"; #define LOG_IF_EVERY_N(severity, condition, n) \ - ABSL_LOG_IF_EVERY_N_IMPL(_##severity, condition, n) + ABSL_LOG_INTERNAL_LOG_IF_EVERY_N_IMPL(_##severity, condition, n) #define LOG_IF_FIRST_N(severity, condition, n) \ - ABSL_LOG_IF_FIRST_N_IMPL(_##severity, condition, n) + ABSL_LOG_INTERNAL_LOG_IF_FIRST_N_IMPL(_##severity, condition, n) #define LOG_IF_EVERY_POW_2(severity, condition) \ - ABSL_LOG_IF_EVERY_POW_2_IMPL(_##severity, condition) + ABSL_LOG_INTERNAL_LOG_IF_EVERY_POW_2_IMPL(_##severity, condition) #define LOG_IF_EVERY_N_SEC(severity, condition, n_seconds) \ - ABSL_LOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds) + ABSL_LOG_INTERNAL_LOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds) #define PLOG_IF_EVERY_N(severity, condition, n) \ - ABSL_PLOG_IF_EVERY_N_IMPL(_##severity, condition, n) + ABSL_LOG_INTERNAL_PLOG_IF_EVERY_N_IMPL(_##severity, condition, n) #define PLOG_IF_FIRST_N(severity, condition, n) \ - ABSL_PLOG_IF_FIRST_N_IMPL(_##severity, condition, n) + ABSL_LOG_INTERNAL_PLOG_IF_FIRST_N_IMPL(_##severity, condition, n) #define PLOG_IF_EVERY_POW_2(severity, condition) \ - ABSL_PLOG_IF_EVERY_POW_2_IMPL(_##severity, condition) + ABSL_LOG_INTERNAL_PLOG_IF_EVERY_POW_2_IMPL(_##severity, condition) #define PLOG_IF_EVERY_N_SEC(severity, condition, n_seconds) \ - ABSL_PLOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds) + ABSL_LOG_INTERNAL_PLOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds) #define DLOG_IF_EVERY_N(severity, condition, n) \ - ABSL_DLOG_IF_EVERY_N_IMPL(_##severity, condition, n) + ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_IMPL(_##severity, condition, n) #define DLOG_IF_FIRST_N(severity, condition, n) \ - ABSL_DLOG_IF_FIRST_N_IMPL(_##severity, condition, n) + ABSL_LOG_INTERNAL_DLOG_IF_FIRST_N_IMPL(_##severity, condition, n) #define DLOG_IF_EVERY_POW_2(severity, condition) \ - ABSL_DLOG_IF_EVERY_POW_2_IMPL(_##severity, condition) + ABSL_LOG_INTERNAL_DLOG_IF_EVERY_POW_2_IMPL(_##severity, condition) #define DLOG_IF_EVERY_N_SEC(severity, condition, n_seconds) \ - ABSL_DLOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds) + ABSL_LOG_INTERNAL_DLOG_IF_EVERY_N_SEC_IMPL(_##severity, condition, n_seconds) #endif // ABSL_LOG_LOG_H_ diff --git a/absl/log/log_basic_test.cc b/absl/log/log_basic_test.cc index b8d87c94..7fc7111d 100644 --- a/absl/log/log_basic_test.cc +++ b/absl/log/log_basic_test.cc @@ -18,4 +18,4 @@ #define ABSL_TEST_LOG LOG #include "gtest/gtest.h" -#include "absl/log/log_basic_test_impl.h" +#include "absl/log/log_basic_test_impl.inc" diff --git a/absl/log/log_basic_test_impl.h b/absl/log/log_basic_test_impl.inc index 35c0b690..f3400095 100644 --- a/absl/log/log_basic_test_impl.h +++ b/absl/log/log_basic_test_impl.inc @@ -94,7 +94,7 @@ TEST_P(BasicLogTest, Info) { EXPECT_CALL( test_sink, Send(AllOf(SourceFilename(Eq(__FILE__)), - SourceBasename(Eq("log_basic_test_impl.h")), + SourceBasename(Eq("log_basic_test_impl.inc")), SourceLine(Eq(log_line)), Prefix(IsTrue()), LogSeverity(Eq(absl::LogSeverity::kInfo)), TimestampInMatchWindow(), @@ -123,7 +123,7 @@ TEST_P(BasicLogTest, Warning) { EXPECT_CALL( test_sink, Send(AllOf(SourceFilename(Eq(__FILE__)), - SourceBasename(Eq("log_basic_test_impl.h")), + SourceBasename(Eq("log_basic_test_impl.inc")), SourceLine(Eq(log_line)), Prefix(IsTrue()), LogSeverity(Eq(absl::LogSeverity::kWarning)), TimestampInMatchWindow(), @@ -152,7 +152,7 @@ TEST_P(BasicLogTest, Error) { EXPECT_CALL( test_sink, Send(AllOf(SourceFilename(Eq(__FILE__)), - SourceBasename(Eq("log_basic_test_impl.h")), + SourceBasename(Eq("log_basic_test_impl.inc")), SourceLine(Eq(log_line)), Prefix(IsTrue()), LogSeverity(Eq(absl::LogSeverity::kError)), TimestampInMatchWindow(), @@ -203,7 +203,7 @@ TEST_P(BasicLogDeathTest, Fatal) { EXPECT_CALL( test_sink, Send(AllOf(SourceFilename(Eq(__FILE__)), - SourceBasename(Eq("log_basic_test_impl.h")), + SourceBasename(Eq("log_basic_test_impl.inc")), SourceLine(Eq(log_line)), Prefix(IsTrue()), LogSeverity(Eq(absl::LogSeverity::kFatal)), TimestampInMatchWindow(), @@ -219,7 +219,7 @@ TEST_P(BasicLogDeathTest, Fatal) { EXPECT_CALL( test_sink, Send(AllOf(SourceFilename(Eq(__FILE__)), - SourceBasename(Eq("log_basic_test_impl.h")), + SourceBasename(Eq("log_basic_test_impl.inc")), SourceLine(Eq(log_line)), Prefix(IsTrue()), LogSeverity(Eq(absl::LogSeverity::kFatal)), TimestampInMatchWindow(), @@ -257,7 +257,7 @@ TEST_P(BasicLogDeathTest, QFatal) { EXPECT_CALL( test_sink, Send(AllOf(SourceFilename(Eq(__FILE__)), - SourceBasename(Eq("log_basic_test_impl.h")), + SourceBasename(Eq("log_basic_test_impl.inc")), SourceLine(Eq(log_line)), Prefix(IsTrue()), LogSeverity(Eq(absl::LogSeverity::kFatal)), TimestampInMatchWindow(), @@ -293,7 +293,7 @@ TEST_P(BasicLogTest, Level) { EXPECT_CALL( test_sink, Send(AllOf(SourceFilename(Eq(__FILE__)), - SourceBasename(Eq("log_basic_test_impl.h")), + SourceBasename(Eq("log_basic_test_impl.inc")), SourceLine(Eq(log_line)), Prefix(IsTrue()), LogSeverity(Eq(severity)), TimestampInMatchWindow(), ThreadID(Eq(absl::base_internal::GetTID())), @@ -336,7 +336,7 @@ TEST_P(BasicLogDeathTest, Level) { EXPECT_CALL( test_sink, Send(AllOf(SourceFilename(Eq(__FILE__)), - SourceBasename(Eq("log_basic_test_impl.h")), + SourceBasename(Eq("log_basic_test_impl.inc")), SourceLine(Eq(log_line)), Prefix(IsTrue()), LogSeverity(Eq(absl::LogSeverity::kFatal)), TimestampInMatchWindow(), @@ -351,7 +351,7 @@ TEST_P(BasicLogDeathTest, Level) { EXPECT_CALL( test_sink, Send(AllOf(SourceFilename(Eq(__FILE__)), - SourceBasename(Eq("log_basic_test_impl.h")), + SourceBasename(Eq("log_basic_test_impl.inc")), SourceLine(Eq(log_line)), Prefix(IsTrue()), LogSeverity(Eq(absl::LogSeverity::kFatal)), TimestampInMatchWindow(), |