- 14488f5397315b265d57b50e6796890107e0efb2 Clarify comment on absl::NormalizeLogSeverity. by Abseil Team <absl-team@google.com> - 401dcf3fdb121e8356e8f54c9f2838faad9ffdf7 Internal change. by Alex Strelnikov <strel@google.com> - 1401400b77f8cb5d11fac414c89ffc3b55713f41 Remove unnecessary extern specifier on function declarati... by Alex Strelnikov <strel@google.com> - 97d1079d0e8930b1d77bda7bac5e4d15e0e74278 Add missing explicit casts between signed and unsigned in... by Alex Strelnikov <strel@google.com> - 47c4138142900de510e4c5426b4bf606252d7dac Internal change. by Alex Strelnikov <strel@google.com> - 40eb2555499a000adb78a6581215c701fa818568 Documentation fixes for `absl::optional`, for the `value_... by Abseil Team <absl-team@google.com> GitOrigin-RevId: 14488f5397315b265d57b50e6796890107e0efb2 Change-Id: I3c11216c0c6ef5633aa5cc3b7f5977fa4a3ea1f5
		
			
				
	
	
		
			61 lines
		
	
	
	
		
			2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			61 lines
		
	
	
	
		
			2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
// Copyright 2017 The Abseil Authors.
 | 
						|
//
 | 
						|
// Licensed under the Apache License, Version 2.0 (the "License");
 | 
						|
// you may not use this file except in compliance with the License.
 | 
						|
// You may obtain a copy of the License at
 | 
						|
//
 | 
						|
//      http://www.apache.org/licenses/LICENSE-2.0
 | 
						|
//
 | 
						|
// Unless required by applicable law or agreed to in writing, software
 | 
						|
// distributed under the License is distributed on an "AS IS" BASIS,
 | 
						|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
						|
// See the License for the specific language governing permissions and
 | 
						|
// limitations under the License.
 | 
						|
//
 | 
						|
 | 
						|
#ifndef ABSL_BASE_INTERNAL_LOG_SEVERITY_H_
 | 
						|
#define ABSL_BASE_INTERNAL_LOG_SEVERITY_H_
 | 
						|
 | 
						|
#include <array>
 | 
						|
 | 
						|
#include "absl/base/attributes.h"
 | 
						|
 | 
						|
namespace absl {
 | 
						|
 | 
						|
enum class LogSeverity : int {
 | 
						|
  kInfo = 0,
 | 
						|
  kWarning = 1,
 | 
						|
  kError = 2,
 | 
						|
  kFatal = 3,
 | 
						|
};
 | 
						|
 | 
						|
// Returns an iterable of all standard `absl::LogSeverity` values, ordered from
 | 
						|
// least to most severe.
 | 
						|
constexpr std::array<absl::LogSeverity, 4> LogSeverities() {
 | 
						|
  return {{absl::LogSeverity::kInfo, absl::LogSeverity::kWarning,
 | 
						|
           absl::LogSeverity::kError, absl::LogSeverity::kFatal}};
 | 
						|
}
 | 
						|
 | 
						|
constexpr const char* LogSeverityName(absl::LogSeverity s) {
 | 
						|
  return s == absl::LogSeverity::kInfo
 | 
						|
             ? "INFO"
 | 
						|
             : s == absl::LogSeverity::kWarning
 | 
						|
                   ? "WARNING"
 | 
						|
                   : s == absl::LogSeverity::kError
 | 
						|
                         ? "ERROR"
 | 
						|
                         : s == absl::LogSeverity::kFatal ? "FATAL" : "UNKNOWN";
 | 
						|
}
 | 
						|
 | 
						|
// Note that out-of-range severities normalize to kInfo or kError, never kFatal.
 | 
						|
constexpr absl::LogSeverity NormalizeLogSeverity(absl::LogSeverity s) {
 | 
						|
  return s < absl::LogSeverity::kInfo
 | 
						|
             ? absl::LogSeverity::kInfo
 | 
						|
             : s > absl::LogSeverity::kFatal ? absl::LogSeverity::kError : s;
 | 
						|
}
 | 
						|
constexpr absl::LogSeverity NormalizeLogSeverity(int s) {
 | 
						|
  return NormalizeLogSeverity(static_cast<absl::LogSeverity>(s));
 | 
						|
}
 | 
						|
 | 
						|
}  // namespace absl
 | 
						|
 | 
						|
#endif  // ABSL_BASE_INTERNAL_LOG_SEVERITY_H_
 |