log level
This commit is contained in:
@@ -4,12 +4,15 @@
|
|||||||
#include <fmt/color.h>
|
#include <fmt/color.h>
|
||||||
|
|
||||||
namespace Util {
|
namespace Util {
|
||||||
enum MessageType : u8 {
|
enum LogLevel : u8 {
|
||||||
Info, Debug, Warn, Error
|
Trace, Info, Debug, Warn, Error
|
||||||
};
|
};
|
||||||
|
|
||||||
template <MessageType messageType = Info, typename ...Args>
|
static constexpr auto globalLogLevel = Warn;
|
||||||
|
|
||||||
|
template <LogLevel messageType = Info, typename ...Args>
|
||||||
constexpr void print(const std::string& fmt, Args... args) {
|
constexpr void print(const std::string& fmt, Args... args) {
|
||||||
|
if constexpr(messageType >= globalLogLevel) {
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
if constexpr(messageType == Error) {
|
if constexpr(messageType == Error) {
|
||||||
fmt::print(fmt::emphasis::bold | fg(fmt::color::red), fmt, args...);
|
fmt::print(fmt::emphasis::bold | fg(fmt::color::red), fmt, args...);
|
||||||
@@ -31,6 +34,7 @@ constexpr void print(const std::string& fmt, Args... args) {
|
|||||||
fmt::print(fmt, args...);
|
fmt::print(fmt, args...);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename ...Args>
|
template <typename ...Args>
|
||||||
|
|||||||
Reference in New Issue
Block a user