From 61b061d55ada00a14d7ef2c1c1caedd3baeace1d Mon Sep 17 00:00:00 2001 From: Riyyi Date: Sat, 9 Jan 2021 23:55:17 +0100 Subject: [PATCH] Add comment as a color to log --- inferno/src/inferno/log.cpp | 9 +++++++-- inferno/src/inferno/log.h | 9 +++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/inferno/src/inferno/log.cpp b/inferno/src/inferno/log.cpp index 9baea6f..7b989db 100644 --- a/inferno/src/inferno/log.cpp +++ b/inferno/src/inferno/log.cpp @@ -126,7 +126,7 @@ namespace Inferno { const LogStream& operator<<(const LogStream& stream, Log value) { switch (value) { - case Log::Log: + case Log::None: return stream << "Log"; case Log::Info: return stream << "Info"; @@ -136,6 +136,8 @@ namespace Inferno { return stream << "Danger"; case Log::Success: return stream << "Success"; + case Log::Comment: + return stream << "Comment"; default: ASSERT_NOT_REACHED(); return stream; @@ -218,7 +220,7 @@ namespace Inferno { DebugLogStream::~DebugLogStream() { - if (m_type != Log::Log) { + if (m_type != Log::None) { write("\033[0m", 4); } @@ -243,6 +245,9 @@ namespace Inferno { else if (m_type == Log::Success) { color = "\x1B[32m"; } + else if (m_type == Log::Comment) { + color = "\x1B[37m"; + } if (color[0] != '\0') { write(color, 5); diff --git a/inferno/src/inferno/log.h b/inferno/src/inferno/log.h index 7978bef..7bb4c0d 100644 --- a/inferno/src/inferno/log.h +++ b/inferno/src/inferno/log.h @@ -8,11 +8,12 @@ namespace Inferno { enum class Log { - Log, + None, Info, Warn, Danger, Success, + Comment, }; // ---------------------------------------- @@ -31,9 +32,9 @@ namespace Inferno { class DebugLogStream final : public LogStream{ public: DebugLogStream(): - m_newline(true), m_type(Log::Log) {} + m_newline(true), m_type(Log::None) {} DebugLogStream(bool newline): - m_newline(newline), m_type(Log::Log) {} + m_newline(newline), m_type(Log::None) {} DebugLogStream(Log type): m_newline(true), m_type(type) { color(); } DebugLogStream(Log type, bool newline): @@ -102,7 +103,7 @@ namespace Inferno { template void dbgln(const char* format, T value, const P&... parameters) { - dbgln(Log::Log, true, format, value, parameters...); + dbgln(Log::None, true, format, value, parameters...); } template