WARN = 3000,
WARNING = 3000,
- // Unfortunately Windows headers #define ERROR
- // On Windows platforms we avoid defining ERROR. However we make it
- // available on other platforms, to make it easier to convert code from
- // other log libraries that also use ERROR as their log level name (e.g.,
- // glog).
+ // Unfortunately Windows headers #define ERROR, so we cannot use
+ // it as an enum value name. We only provide ERR instead.
ERR = 4000,
-#ifndef ERROR
- ERROR = 4000,
-#endif
CRITICAL = 5000,
* adjusted log level values.
*/
inline constexpr LogLevel operator+(LogLevel level, uint32_t value) {
- auto newValue = static_cast<uint32_t>(level) + value;
// Cap the result at LogLevel::MAX_LEVEL
- if (newValue > static_cast<uint32_t>(LogLevel::MAX_LEVEL)) {
- return LogLevel::MAX_LEVEL;
- }
- return static_cast<LogLevel>(newValue);
+ return ((static_cast<uint32_t>(level) + value) >
+ static_cast<uint32_t>(LogLevel::MAX_LEVEL))
+ ? LogLevel::MAX_LEVEL
+ : static_cast<LogLevel>(static_cast<uint32_t>(level) + value);
}
inline LogLevel& operator+=(LogLevel& level, uint32_t value) {
level = level + value;
* Returns true if and only if a LogLevel is fatal.
*/
inline constexpr bool isLogLevelFatal(LogLevel level) {
- if (folly::kIsDebug) {
- return level >= LogLevel::DFATAL;
- } else {
- return level >= LogLevel::FATAL;
- }
-}
+ return folly::kIsDebug ? (level >= LogLevel::DFATAL)
+ : (level >= LogLevel::FATAL);
}
+} // namespace folly