aboutsummaryrefslogtreecommitdiff
path: root/src/zenutil/logging.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2025-03-12 13:54:16 +0100
committerGitHub Enterprise <[email protected]>2025-03-12 13:54:16 +0100
commit7046fc9dc202307ba92d05a6386bfb52e9db0ab9 (patch)
treeecd3db4fd57fecc88bb5e9702e4d91a6e8e16027 /src/zenutil/logging.cpp
parent5.6.1-pre0 (diff)
downloadzen-7046fc9dc202307ba92d05a6386bfb52e9db0ab9.tar.xz
zen-7046fc9dc202307ba92d05a6386bfb52e9db0ab9.zip
fixes for log timestamps (#304)
* add GetTimeSinceProcessStart returning time since process start. implemented using https://github.com/maxliani/GetTimeSinceProcessStart/tree/main * fix fractions when using epoch mode. Previously it would show the fraction from the absolute time stamp and not relative to epoch * used GetTimeSinceProcessStart to offset the epoch so that it represents the process spawn time
Diffstat (limited to 'src/zenutil/logging.cpp')
-rw-r--r--src/zenutil/logging.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/zenutil/logging.cpp b/src/zenutil/logging.cpp
index 762b75a59..cb0fd6679 100644
--- a/src/zenutil/logging.cpp
+++ b/src/zenutil/logging.cpp
@@ -16,6 +16,7 @@ ZEN_THIRD_PARTY_INCLUDES_END
#include <zencore/logging.h>
#include <zencore/memory/llm.h>
#include <zencore/string.h>
+#include <zencore/timer.h>
#include <zenutil/logging/fullformatter.h>
#include <zenutil/logging/jsonformatter.h>
#include <zenutil/logging/rotatingfilesink.h>
@@ -191,8 +192,9 @@ FinishInitializeLogging(const LoggingOptions& LogOptions)
logging::RefreshLogLevels(LogLevel);
spdlog::flush_on(spdlog::level::err);
spdlog::flush_every(std::chrono::seconds{2});
- spdlog::set_formatter(
- std::make_unique<logging::full_formatter>(LogOptions.LogId, std::chrono::system_clock::now())); // default to duration prefix
+ spdlog::set_formatter(std::make_unique<logging::full_formatter>(
+ LogOptions.LogId,
+ std::chrono::system_clock::now() - std::chrono::milliseconds(GetTimeSinceProcessStart()))); // default to duration prefix
if (g_FileSink)
{