aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2026-04-11 23:58:34 +0200
committerStefan Boberg <[email protected]>2026-04-11 23:58:34 +0200
commit5b5b81333e03ae4ccf2ca51185120ab05d6deb32 (patch)
treeac56f5801204639cfd9762821399460f0a79a8be
parentFix Windows steps in manual test workflow to use PowerShell (diff)
downloadzen-sb/logging-improvements.tar.xz
zen-sb/logging-improvements.zip
Highlight logger name in log outputsb/logging-improvements
- Add bright white (97m) color to logger name in ANSI color sink - Add bold (1m) color to logger name in full formatter - Remove unused m_UseFullDate default initializer
-rw-r--r--src/zencore/logging/ansicolorsink.cpp10
-rw-r--r--src/zenutil/logging/fullformatter.cpp11
2 files changed, 20 insertions, 1 deletions
diff --git a/src/zencore/logging/ansicolorsink.cpp b/src/zencore/logging/ansicolorsink.cpp
index c11b3760d..1a8201876 100644
--- a/src/zencore/logging/ansicolorsink.cpp
+++ b/src/zencore/logging/ansicolorsink.cpp
@@ -68,12 +68,22 @@ public:
Dest.push_back(']');
Dest.push_back(' ');
+ using namespace std::literals;
+
// logger name
if (Msg.GetLoggerName().size() > 0)
{
+ if (IsColorEnabled())
+ {
+ Dest.append("\033[97m"sv);
+ }
Dest.push_back('[');
helpers::AppendStringView(Msg.GetLoggerName(), Dest);
Dest.push_back(']');
+ if (IsColorEnabled())
+ {
+ Dest.append("\033[0m"sv);
+ }
Dest.push_back(' ');
}
diff --git a/src/zenutil/logging/fullformatter.cpp b/src/zenutil/logging/fullformatter.cpp
index 33e6d3161..283a8bc37 100644
--- a/src/zenutil/logging/fullformatter.cpp
+++ b/src/zenutil/logging/fullformatter.cpp
@@ -12,6 +12,7 @@
#include <atomic>
#include <chrono>
#include <string>
+#include "zencore/logging.h"
namespace zen::logging {
@@ -25,7 +26,7 @@ struct FullFormatter::Impl
{
}
- explicit Impl(std::string_view LogId) : m_LogId(LogId), m_LinePrefix(128, ' '), m_UseFullDate(true) {}
+ explicit Impl(std::string_view LogId) : m_LogId(LogId), m_LinePrefix(128, ' ') {}
std::chrono::time_point<std::chrono::system_clock> m_Epoch;
std::tm m_CachedLocalTm{};
@@ -172,9 +173,17 @@ FullFormatter::Format(const LogMessage& Msg, MemoryBuffer& OutBuffer)
// logger name
if (Msg.GetLoggerName().size() > 0)
{
+ if (IsColorEnabled())
+ {
+ OutBuffer.append("\033[1m"sv);
+ }
OutBuffer.push_back('[');
helpers::AppendStringView(Msg.GetLoggerName(), OutBuffer);
OutBuffer.push_back(']');
+ if (IsColorEnabled())
+ {
+ OutBuffer.append("\033[0m"sv);
+ }
OutBuffer.push_back(' ');
}