aboutsummaryrefslogtreecommitdiff
path: root/src/zenutil/logging
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2026-04-23 18:16:57 +0200
committerStefan Boberg <[email protected]>2026-04-23 18:16:57 +0200
commit0232b991cd7d8e3a2114ea30e4591dd3e7b65c36 (patch)
tree94730e7594fd09ae1fa820391ce311f6daf13905 /src/zenutil/logging
parentFix forward declaration order for s_GotSigWinch and SigWinchHandler (diff)
parenttrace: declare Region event name fields as AnsiString (#1012) (diff)
downloadarchived-zen-sb/zen-help.tar.xz
archived-zen-sb/zen-help.zip
Merge branch 'main' into sb/zen-helpsb/zen-help
- Combine HelpCommand (this branch) with HistoryCommand (main) in zen CLI dispatcher - Keep filter-aware TuiPickOne rewrite; adopt main's ASCII arrow glyphs in doc comment
Diffstat (limited to 'src/zenutil/logging')
-rw-r--r--src/zenutil/logging/fullformatter.cpp30
-rw-r--r--src/zenutil/logging/logging.cpp10
-rw-r--r--src/zenutil/logging/rotatingfilesink.cpp2
3 files changed, 28 insertions, 14 deletions
diff --git a/src/zenutil/logging/fullformatter.cpp b/src/zenutil/logging/fullformatter.cpp
index 2a4840241..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{};
@@ -155,15 +156,7 @@ FullFormatter::Format(const LogMessage& Msg, MemoryBuffer& OutBuffer)
OutBuffer.push_back(' ');
}
- // append logger name if exists
- if (Msg.GetLoggerName().size() > 0)
- {
- OutBuffer.push_back('[');
- helpers::AppendStringView(Msg.GetLoggerName(), OutBuffer);
- OutBuffer.push_back(']');
- OutBuffer.push_back(' ');
- }
-
+ // level
OutBuffer.push_back('[');
if (IsColorEnabled())
{
@@ -177,6 +170,23 @@ FullFormatter::Format(const LogMessage& Msg, MemoryBuffer& OutBuffer)
OutBuffer.push_back(']');
OutBuffer.push_back(' ');
+ // 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(' ');
+ }
+
// add source location if present
if (Msg.GetSource())
{
diff --git a/src/zenutil/logging/logging.cpp b/src/zenutil/logging/logging.cpp
index aa34fc50c..936e3c4fd 100644
--- a/src/zenutil/logging/logging.cpp
+++ b/src/zenutil/logging/logging.cpp
@@ -124,7 +124,7 @@ BeginInitializeLogging(const LoggingOptions& LogOptions)
LoggerRef DefaultLogger = zen::logging::Default();
- // Build the broadcast sink — a shared indirection point that all
+ // Build the broadcast sink - a shared indirection point that all
// loggers cloned from the default will share. Adding or removing
// a child sink later is immediately visible to every logger.
std::vector<logging::SinkPtr> BroadcastChildren;
@@ -158,6 +158,10 @@ BeginInitializeLogging(const LoggingOptions& LogOptions)
}
#endif
+ // Trace forwarding is installed at a lower level (in Logger::Log itself)
+ // so it can see the typed fmt argument pack before vformat collapses it
+ // to a string - see src/zencore/logging/tracelog.cpp.
+
g_BroadcastSink = Ref<logging::BroadcastSink>(new logging::BroadcastSink(std::move(BroadcastChildren)));
bool IsAsync = LogOptions.AllowAsync && !LogOptions.IsDebug && !LogOptions.IsTest;
@@ -179,7 +183,7 @@ BeginInitializeLogging(const LoggingOptions& LogOptions)
{
return;
}
- static constinit logging::LogPoint ErrorPoint{{}, logging::Err, "{}"};
+ static constinit logging::LogPoint ErrorPoint{0, 0, logging::Err, "{}"};
if (auto ErrLogger = zen::logging::ErrorLog())
{
try
@@ -249,7 +253,7 @@ FinishInitializeLogging(const LoggingOptions& LogOptions)
const std::string StartLogTime = zen::DateTime::Now().ToIso8601();
logging::Registry::Instance().ApplyAll([&](auto Logger) {
- static constinit logging::LogPoint LogStartPoint{{}, logging::Info, "log starting at {}"};
+ static constinit logging::LogPoint LogStartPoint{0, 0, logging::Info, "log starting at {}"};
Logger->Log(LogStartPoint, fmt::make_format_args(StartLogTime));
});
}
diff --git a/src/zenutil/logging/rotatingfilesink.cpp b/src/zenutil/logging/rotatingfilesink.cpp
index 23cf60d16..df59af5fe 100644
--- a/src/zenutil/logging/rotatingfilesink.cpp
+++ b/src/zenutil/logging/rotatingfilesink.cpp
@@ -85,7 +85,7 @@ struct RotatingFileSink::Impl
m_CurrentSize = m_CurrentFile.FileSize(OutEc);
if (OutEc)
{
- // FileSize failed but we have an open file — reset to 0
+ // FileSize failed but we have an open file - reset to 0
// so we can at least attempt writes from the start
m_CurrentSize = 0;
OutEc.clear();