From 4874a49aaabb598bbcbb648a43ba8a9618806aff Mon Sep 17 00:00:00 2001 From: Alexandre Date: Fri, 9 Oct 2026 22:59:00 +0200 Subject: [PATCH] Fixed dependency for glibc or smth ig --- src/Common/Logger.h | 19 +++++++++++++++---- src/Common/Types.h | 2 ++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Common/Logger.h b/src/Common/Logger.h index c407e18..b587df6 100644 --- a/src/Common/Logger.h +++ b/src/Common/Logger.h @@ -110,6 +110,9 @@ class Logger { // Helper functions static std::string_view moduleToString(LogModule m); static std::string_view levelToString(LogLevel l); + inline std::string formatTimestamp( + std::chrono::system_clock::time_point tp + ); }; #endif // End of header @@ -140,8 +143,7 @@ void Logger::logRAM( Args&&... args ) { auto now { std::chrono::system_clock::now() }; - now = std::chrono::zoned_time{ std::chrono::current_zone(), now }; - auto timestamp = std::format("{:%Y-%m-%d %H:%M}", now); + auto timestamp = formatTimestamp(now); auto start = logBuffer.size(); fmt::format_to( @@ -177,7 +179,7 @@ void Logger::logConsole( ) { std::string tempBuffer; auto now = std::chrono::system_clock::now(); - auto timestamp = std::format("{:%Y-%m-%d %H:%M}", now); + auto timestamp = formatTimestamp(now); fmt::format_to( std::back_inserter(tempBuffer), @@ -219,7 +221,7 @@ void Logger::logDisk( // Create a temporary buffer std::string tempBuffer; auto now = std::chrono::system_clock::now(); - auto timestamp = std::format("{:%Y-%m-%d %H:%M}", now); + auto timestamp = formatTimestamp(now); fmt::format_to( std::back_inserter(tempBuffer), @@ -379,5 +381,14 @@ std::string_view Logger::levelToString(LogLevel l) { } } +std::string Logger::formatTimestamp( + std::chrono::system_clock::time_point tp +) { + std::time_t t = std::chrono::system_clock::to_time_t(tp); + std::tm tm{}; + localtime_r(&t, &tm); + return fmt::format("{:%Y-%m-%d %H:%M}", tm); +} + #endif #endif diff --git a/src/Common/Types.h b/src/Common/Types.h index 8037c46..7c6803b 100644 --- a/src/Common/Types.h +++ b/src/Common/Types.h @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include #include