mirror of
https://github.com/KjellKod/g3log.git
synced 2024-12-12 10:23:50 +01:00
constexpr LEVELS for easier custom level usage (#483)
Usage of C++20's new constexpr functionalities for easier usage of custom LEVELS! Modified: * With C++20 LEVELS's constructor can have a constexpr specifier * const LEVELS can be replaced to be constexpr's instead
This commit is contained in:
parent
b249fb6c6c
commit
cc0fb7c1ea
@ -34,6 +34,10 @@ struct LEVELS {
|
|||||||
// "dynamic, runtime loading of shared libraries"
|
// "dynamic, runtime loading of shared libraries"
|
||||||
|
|
||||||
LEVELS(const LEVELS& other): value(other.value), text(other.text.c_str()) {}
|
LEVELS(const LEVELS& other): value(other.value), text(other.text.c_str()) {}
|
||||||
|
|
||||||
|
#if __cplusplus >= 202002L
|
||||||
|
constexpr
|
||||||
|
#endif
|
||||||
LEVELS(int id, const std::string& idtext) : value(id), text(idtext) {}
|
LEVELS(int id, const std::string& idtext) : value(id), text(idtext) {}
|
||||||
|
|
||||||
bool operator==(const LEVELS& rhs) const {
|
bool operator==(const LEVELS& rhs) const {
|
||||||
@ -90,11 +94,15 @@ namespace g3 {
|
|||||||
static const int kInternalFatalValue = 2000;
|
static const int kInternalFatalValue = 2000;
|
||||||
} // g3
|
} // g3
|
||||||
|
|
||||||
|
#if __cplusplus >= 202002L
|
||||||
const LEVELS G3LOG_DEBUG{g3::kDebugValue, {"DEBUG"}},
|
constexpr
|
||||||
INFO {g3::kInfoValue, {"INFO"}},
|
#else
|
||||||
WARNING {g3::kWarningValue, {"WARNING"}},
|
const
|
||||||
FATAL {g3::kFatalValue, {"FATAL"}};
|
#endif
|
||||||
|
LEVELS G3LOG_DEBUG{g3::kDebugValue, "DEBUG"},
|
||||||
|
INFO {g3::kInfoValue, "INFO"},
|
||||||
|
WARNING {g3::kWarningValue, "WARNING"},
|
||||||
|
FATAL {g3::kFatalValue, "FATAL"};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -129,7 +137,12 @@ namespace g3 {
|
|||||||
|
|
||||||
namespace g3 {
|
namespace g3 {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
const LEVELS CONTRACT {g3::kInternalFatalValue, {"CONTRACT"}},
|
#if __cplusplus >= 202002L
|
||||||
|
constexpr
|
||||||
|
#else
|
||||||
|
const
|
||||||
|
#endif
|
||||||
|
LEVELS CONTRACT {g3::kInternalFatalValue, {"CONTRACT"}},
|
||||||
FATAL_SIGNAL {g3::kInternalFatalValue + 1, {"FATAL_SIGNAL"}},
|
FATAL_SIGNAL {g3::kInternalFatalValue + 1, {"FATAL_SIGNAL"}},
|
||||||
FATAL_EXCEPTION {kInternalFatalValue + 2, {"FATAL_EXCEPTION"}};
|
FATAL_EXCEPTION {kInternalFatalValue + 2, {"FATAL_EXCEPTION"}};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user