From 739ed828afd726753819725326261dc2c7d9da33 Mon Sep 17 00:00:00 2001 From: yagi Date: Sat, 7 Feb 2026 02:23:33 +0900 Subject: [PATCH 1/2] refactor: Changed to output log time in ISO8601 format. --- retinify/src/logging.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/retinify/src/logging.cpp b/retinify/src/logging.cpp index ba9aa69..7504378 100644 --- a/retinify/src/logging.cpp +++ b/retinify/src/logging.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -92,16 +93,28 @@ struct LogMetadata [[nodiscard]] auto GetCurrentTime() -> std::string { - const std::chrono::system_clock::time_point currentTimePoint = std::chrono::system_clock::now(); - const std::time_t currentTimeT = std::chrono::system_clock::to_time_t(currentTimePoint); - std::tm localTimeStruct{}; - if (localtime_r(¤tTimeT, &localTimeStruct) == nullptr) + const std::time_t now = std::time(nullptr); + + std::tm utc{}; +#if defined(_WIN32) + if (gmtime_s(&utc, &now) != 0) + { + return {}; + } +#else + if (gmtime_r(&now, &utc) == nullptr) { - return std::string{"Invalid time"}; + return {}; } - std::ostringstream timeStream; - timeStream << std::put_time(&localTimeStruct, "%F %T"); - return timeStream.str(); +#endif + + char buffer[32]; + if (std::strftime(buffer, sizeof(buffer), "%Y-%m-%dT%H:%M:%SZ", &utc) == 0) + { + return {}; + } + + return buffer; } inline auto Log(LogLevel level, const char *message, std::source_location location) noexcept -> void From 9f07de44a6c26369d9d6de85fb987f13d195ddc6 Mon Sep 17 00:00:00 2001 From: yagi Date: Sat, 7 Feb 2026 16:34:52 +0900 Subject: [PATCH 2/2] refactor: remove unused header from logging.cpp --- retinify/src/logging.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/retinify/src/logging.cpp b/retinify/src/logging.cpp index 7504378..3acc2e9 100644 --- a/retinify/src/logging.cpp +++ b/retinify/src/logging.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include