From 61c7e6c8961596f4a28568a4c95681e5e9312386 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 10:18:57 +0000 Subject: [PATCH] Log: add UTC offset to log timestamps Timestamps are now formatted with strftime("%Y-%m-%d %H:%M:%S%z"), e.g. "2026-11-26 12:14:55+0200", so log lines are unambiguous across time zones and daylight-saving changes. Applies to all log modes that include time (_LOG_TIME, _LOG_TIME_PTR, _LOG_LVL_TIME, _LOG_LVL_TIME_PTR); the rest of the line format is unchanged. In GMT mode the offset is +0000. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16 --- lib/components/base/basicLogCollection.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/components/base/basicLogCollection.cpp b/lib/components/base/basicLogCollection.cpp index ab93734a..c395f1e4 100644 --- a/lib/components/base/basicLogCollection.cpp +++ b/lib/components/base/basicLogCollection.cpp @@ -91,30 +91,36 @@ void basicLogCollection::Log(const char * Mod, void * ptr, _LOG_LEVEL Level, CST return; } #endif + // Timestamp with UTC offset, e.g. "2026-11-26 12:14:55+0200" (local time) or "+0000" (GMT mode) + char tsStr[40]; + if (strftime(tsStr, sizeof(tsStr), "%Y-%m-%d %H:%M:%S%z", gmt_time) == 0) + { + tsStr[0] = (char) 0; + } switch (m_bLogSettings) { case _LOG_SIMPLE: sprintf(temp, "%s: %s\n", Mod, Msg); break; case _LOG_TIME: { - sprintf(temp, "%04d-%02d-%02d %02d:%02d:%02d %s: %s\n", 1900 + gmt_time->tm_year, 1 + gmt_time->tm_mon, gmt_time->tm_mday, gmt_time->tm_hour, gmt_time->tm_min, gmt_time->tm_sec, Mod, Msg); + sprintf(temp, "%s %s: %s\n", tsStr, Mod, Msg); break; }; case _LOG_PTR: sprintf(temp, "%p %s: %s\n", ptr, Mod, Msg); break; case _LOG_TIME_PTR: { - sprintf(temp, "%04d-%02d-%02d %02d:%02d:%02d %p %s: %s\n", 1900 + gmt_time->tm_year, 1 + gmt_time->tm_mon, gmt_time->tm_mday, gmt_time->tm_hour, gmt_time->tm_min, gmt_time->tm_sec, ptr, Mod, Msg); + sprintf(temp, "%s %p %s: %s\n", tsStr, ptr, Mod, Msg); break; }; case _LOG_LVL: sprintf(temp, "%02X %s: %s\n", Level, Mod, Msg); break; case _LOG_LVL_TIME: { - sprintf(temp, "%02X %04d-%02d-%02d %02d:%02d:%02d %s: %s\n", Level, 1900 + gmt_time->tm_year, 1 + gmt_time->tm_mon, gmt_time->tm_mday, gmt_time->tm_hour, gmt_time->tm_min, gmt_time->tm_sec, Mod, Msg); + sprintf(temp, "%02X %s %s: %s\n", Level, tsStr, Mod, Msg); break; }; case _LOG_LVL_PTR: sprintf(temp, "%02X %p %s: %s\n", Level, ptr, Mod, Msg); break; case _LOG_LVL_TIME_PTR: { - sprintf(temp, "%02X %04d-%02d-%02d %02d:%02d:%02d %p %s: %s\n", Level, 1900 + gmt_time->tm_year, 1 + gmt_time->tm_mon, gmt_time->tm_mday, gmt_time->tm_hour, gmt_time->tm_min, gmt_time->tm_sec, ptr, Mod, Msg); + sprintf(temp, "%02X %s %p %s: %s\n", Level, tsStr, ptr, Mod, Msg); break; }; }; -- 2.39.5