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:
RH 2024-03-25 15:56:22 +11:00 committed by GitHub
parent d1cf78baa6
commit f0c0c75979
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 0 deletions

View File

@ -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:

View File

@ -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__)