All Classes Files Functions Variables Typedefs Pages
LogLevel.hpp
1 #pragma once
2 
3 #include <cstdint>
4 
5 namespace lumina {
6 
7 using LogLevelBaseType = uint8_t;
8 
9 enum class LogLevel : LogLevelBaseType {
10  Critical,
11  Error,
12  Warning,
13  Notice,
14  Info,
15  Debug
16 };
17 
18 inline bool operator<(LogLevel a, LogLevel b) {
19  return static_cast<LogLevelBaseType>(a) > static_cast<LogLevelBaseType>(b);
20 }
21 inline bool operator>(LogLevel a, LogLevel b) {
22  return static_cast<LogLevelBaseType>(a) < static_cast<LogLevelBaseType>(b);
23 }
24 inline bool operator<=(LogLevel a, LogLevel b) {
25  return static_cast<LogLevelBaseType>(a) >= static_cast<LogLevelBaseType>(b);
26 }
27 inline bool operator>=(LogLevel a, LogLevel b) {
28  return static_cast<LogLevelBaseType>(a) <= static_cast<LogLevelBaseType>(b);
29 }
30 
31 
32 template <LogLevel LL> struct LogLevelTrait;
33 
34 #define XLogLevelTraits(level_, string_) \
35  template <> struct LogLevelTrait<LogLevel::level_> { \
36  static constexpr char const* string = string_; \
37  };
38 
39 XLogLevelTraits(Critical, "CRIT")
40 XLogLevelTraits(Error, "ERROR")
41 XLogLevelTraits(Warning, "WARN")
42 XLogLevelTraits(Notice, "NOTE")
43 XLogLevelTraits(Info, "INFO")
44 XLogLevelTraits(Debug, "DEBUG")
45 
46 #undef XLogLevelTraits
47 
48 
49 }
Definition: LogLevel.hpp:32