blob: 6847e69cbe4c79f27eadb9296bd3851304f94fe7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#ifndef INCLUDED_SRC_BUILDTOOL_LOGGING_LOG_LEVEL_HPP
#define INCLUDED_SRC_BUILDTOOL_LOGGING_LOG_LEVEL_HPP
#include <algorithm>
#include <string>
#include <type_traits>
enum class LogLevel {
Error, ///< Error messages, fatal errors
Warning, ///< Warning messages, recoverable situations that shouldn't occur
Info, ///< Informative messages, such as reporting status or statistics
Debug, ///< Debug messages, such as details from internal processes
Trace ///< Trace messages, verbose details such as function calls
};
constexpr auto kFirstLogLevel = LogLevel::Error;
constexpr auto kLastLogLevel = LogLevel::Trace;
[[nodiscard]] static inline auto ToLogLevel(
std::underlying_type_t<LogLevel> level) -> LogLevel {
return std::min(std::max(static_cast<LogLevel>(level), kFirstLogLevel),
kLastLogLevel);
}
[[nodiscard]] static inline auto LogLevelToString(LogLevel level)
-> std::string {
switch (level) {
case LogLevel::Error:
return "ERROR";
case LogLevel::Warning:
return "WARN";
case LogLevel::Info:
return "INFO";
case LogLevel::Debug:
return "DEBUG";
case LogLevel::Trace:
return "TRACE";
}
}
#endif // INCLUDED_SRC_BUILDTOOL_LOGGING_LOG_LEVEL_HPP
|