summaryrefslogtreecommitdiff
path: root/absl/base
diff options
context:
space:
mode:
authorGravatar Derek Mauro <dmauro@google.com>2023-08-04 13:54:47 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2023-08-04 13:55:54 -0700
commit70172ada858b8739ce07e8c2f1ecd8c11c8768c7 (patch)
treee59640940355eb71082261dd9f5c87ae1aa31e78 /absl/base
parent659b77b713fe5f1f75e6e1bb121c0eed1c8f964a (diff)
Release the `DFATAL` pseudo-LogSeverity level
`DFATAL` is defined as `FATAL` in debug mode, and as `ERROR` when `NDEBUG` is defined. Closes #1279 PiperOrigin-RevId: 553904244 Change-Id: Iaa207ee65b2a39b4b7f5da241208c3d39cd5da0e
Diffstat (limited to 'absl/base')
-rw-r--r--absl/base/CMakeLists.txt1
-rw-r--r--absl/base/log_severity.cc1
-rw-r--r--absl/base/log_severity.h12
3 files changed, 14 insertions, 0 deletions
diff --git a/absl/base/CMakeLists.txt b/absl/base/CMakeLists.txt
index 76c4ff1d..c3271a10 100644
--- a/absl/base/CMakeLists.txt
+++ b/absl/base/CMakeLists.txt
@@ -49,6 +49,7 @@ absl_cc_library(
SRCS
"log_severity.cc"
DEPS
+ absl::config
absl::core_headers
COPTS
${ABSL_DEFAULT_COPTS}
diff --git a/absl/base/log_severity.cc b/absl/base/log_severity.cc
index 60a8fc1f..8e7bbbc9 100644
--- a/absl/base/log_severity.cc
+++ b/absl/base/log_severity.cc
@@ -17,6 +17,7 @@
#include <ostream>
#include "absl/base/attributes.h"
+#include "absl/base/config.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
diff --git a/absl/base/log_severity.h b/absl/base/log_severity.h
index 8bdca38b..c8bcd2fd 100644
--- a/absl/base/log_severity.h
+++ b/absl/base/log_severity.h
@@ -64,6 +64,8 @@ ABSL_NAMESPACE_BEGIN
// --my_log_level=info
// --my_log_level=0
//
+// `DFATAL` and `kLogDebugFatal` are similarly accepted.
+//
// Unparsing a flag produces the same result as `absl::LogSeverityName()` for
// the standard levels and a base-ten integer otherwise.
enum class LogSeverity : int {
@@ -82,6 +84,16 @@ constexpr std::array<absl::LogSeverity, 4> LogSeverities() {
absl::LogSeverity::kError, absl::LogSeverity::kFatal}};
}
+// `absl::kLogDebugFatal` equals `absl::LogSeverity::kFatal` in debug builds
+// (i.e. when `NDEBUG` is not defined) and `absl::LogSeverity::kError`
+// otherwise. Avoid ODR-using this variable as it has internal linkage and thus
+// distinct storage in different TUs.
+#ifdef NDEBUG
+static constexpr absl::LogSeverity kLogDebugFatal = absl::LogSeverity::kError;
+#else
+static constexpr absl::LogSeverity kLogDebugFatal = absl::LogSeverity::kFatal;
+#endif
+
// LogSeverityName()
//
// Returns the all-caps string representation (e.g. "INFO") of the specified