mirror of https://github.com/axmolengine/axmol.git
Add support for verbose trace level logging (#1764)
* Add support for verbose trace level logging * Set trace log color to white and debug log color to cyan
This commit is contained in:
parent
d1cf78baa6
commit
f0c0c75979
|
@ -118,6 +118,9 @@ AX_API LogItem& preprocessLog(LogItem&& item)
|
|||
std::string_view levelName;
|
||||
switch (item.level_)
|
||||
{
|
||||
case LogLevel::Trace:
|
||||
levelName = "T/"sv;
|
||||
break;
|
||||
case LogLevel::Debug:
|
||||
levelName = "D/"sv;
|
||||
break;
|
||||
|
@ -140,6 +143,10 @@ AX_API LogItem& preprocessLog(LogItem&& item)
|
|||
constexpr auto colorCodeOfLevel = [](LogLevel level) -> std::string_view {
|
||||
switch (level)
|
||||
{
|
||||
case LogLevel::Trace:
|
||||
return "\x1b[37m"sv;
|
||||
case LogLevel::Debug:
|
||||
return "\x1b[36m"sv;
|
||||
case LogLevel::Info:
|
||||
return "\x1b[92m"sv;
|
||||
case LogLevel::Warn:
|
||||
|
|
|
@ -59,6 +59,7 @@ NS_AX_BEGIN
|
|||
|
||||
enum class LogLevel
|
||||
{
|
||||
Trace,
|
||||
Debug,
|
||||
Info,
|
||||
Warn,
|
||||
|
@ -163,6 +164,7 @@ inline void printLogT(_FmtType&& fmt, LogItem& item, _Types&&... args)
|
|||
#define AXLOG_WITH_LEVEL(level, fmtOrMsg, ...) \
|
||||
ax::printLogT(FMT_COMPILE("{}" fmtOrMsg), ax::preprocessLog(ax::LogItem{level}), ##__VA_ARGS__)
|
||||
|
||||
#define AXLOGT(fmtOrMsg, ...) AXLOG_WITH_LEVEL(ax::LogLevel::Trace, fmtOrMsg, ##__VA_ARGS__)
|
||||
#define AXLOGD(fmtOrMsg, ...) AXLOG_WITH_LEVEL(ax::LogLevel::Debug, fmtOrMsg, ##__VA_ARGS__)
|
||||
#define AXLOGI(fmtOrMsg, ...) AXLOG_WITH_LEVEL(ax::LogLevel::Info, fmtOrMsg, ##__VA_ARGS__)
|
||||
#define AXLOGW(fmtOrMsg, ...) AXLOG_WITH_LEVEL(ax::LogLevel::Warn, fmtOrMsg, ##__VA_ARGS__)
|
||||
|
|
Loading…
Reference in New Issue