summaryrefslogtreecommitdiff
path: root/absl/base
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2023-09-20 15:45:34 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2023-09-20 15:46:37 -0700
commit1f220d57f4968ac65be51dc0f4d659ce4760cfbb (patch)
treedebb174e8394ce93ccff887369c3a9cef7f65bcf /absl/base
parentc45a4393c075fb0e50e408d9b69035a42ed2617c (diff)
Rolling back cl/565792699
PiperOrigin-RevId: 567102456 Change-Id: I0750284c36850adbabc5ec0b4a2635aa8a967e53
Diffstat (limited to 'absl/base')
-rw-r--r--absl/base/log_severity.h21
1 files changed, 10 insertions, 11 deletions
diff --git a/absl/base/log_severity.h b/absl/base/log_severity.h
index d0795a2d..c8bcd2fd 100644
--- a/absl/base/log_severity.h
+++ b/absl/base/log_severity.h
@@ -99,13 +99,13 @@ static constexpr absl::LogSeverity kLogDebugFatal = absl::LogSeverity::kFatal;
// Returns the all-caps string representation (e.g. "INFO") of the specified
// severity level if it is one of the standard levels and "UNKNOWN" otherwise.
constexpr const char* LogSeverityName(absl::LogSeverity s) {
- switch (s) {
- case absl::LogSeverity::kInfo: return "INFO";
- case absl::LogSeverity::kWarning: return "WARNING";
- case absl::LogSeverity::kError: return "ERROR";
- case absl::LogSeverity::kFatal: return "FATAL";
- default: return "UNKNOWN";
- }
+ return s == absl::LogSeverity::kInfo
+ ? "INFO"
+ : s == absl::LogSeverity::kWarning
+ ? "WARNING"
+ : s == absl::LogSeverity::kError
+ ? "ERROR"
+ : s == absl::LogSeverity::kFatal ? "FATAL" : "UNKNOWN";
}
// NormalizeLogSeverity()
@@ -113,10 +113,9 @@ constexpr const char* LogSeverityName(absl::LogSeverity s) {
// Values less than `kInfo` normalize to `kInfo`; values greater than `kFatal`
// normalize to `kError` (**NOT** `kFatal`).
constexpr absl::LogSeverity NormalizeLogSeverity(absl::LogSeverity s) {
- absl::LogSeverity n = s;
- if (n < absl::LogSeverity::kInfo) n = absl::LogSeverity::kInfo;
- if (n > absl::LogSeverity::kFatal) n = absl::LogSeverity::kError;
- return n;
+ return s < absl::LogSeverity::kInfo
+ ? absl::LogSeverity::kInfo
+ : s > absl::LogSeverity::kFatal ? absl::LogSeverity::kError : s;
}
constexpr absl::LogSeverity NormalizeLogSeverity(int s) {
return absl::NormalizeLogSeverity(static_cast<absl::LogSeverity>(s));