NONE = 1,
MIN_LEVEL = 1,
- DEBUG = 900,
+ // "DBG" is the lowest (aka most verbose) debug log level.
+ // This level is intended to be primarily used in log category settings.
+ // In your code it is usually better to use one of the finer-grained DBGn
+ // levels. In your log category settings you can then set the log category
+ // level to a specific DBGn level, or to to main DBG level to enable all DBGn
+ // messages.
+ //
+ // This is named "DBG" rather than "DEBUG" since some open source projects
+ // define "DEBUG" as a preprocessor macro.
+ DBG = 900,
+
DBG0 = 1000,
DBG1 = 999,
DBG2 = 998,
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,
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;
return folly::kIsDebug ? (level >= LogLevel::DFATAL)
: (level >= LogLevel::FATAL);
}
-}
+} // namespace folly