diff options
| author | Stefan Boberg <[email protected]> | 2025-03-12 13:54:16 +0100 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2025-03-12 13:54:16 +0100 |
| commit | 7046fc9dc202307ba92d05a6386bfb52e9db0ab9 (patch) | |
| tree | ecd3db4fd57fecc88bb5e9702e4d91a6e8e16027 /src/zenutil/include | |
| parent | 5.6.1-pre0 (diff) | |
| download | zen-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/include')
| -rw-r--r-- | src/zenutil/include/zenutil/logging/fullformatter.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/zenutil/include/zenutil/logging/fullformatter.h b/src/zenutil/include/zenutil/logging/fullformatter.h index 07ad408fa..0326870e5 100644 --- a/src/zenutil/include/zenutil/logging/fullformatter.h +++ b/src/zenutil/include/zenutil/logging/fullformatter.h @@ -45,6 +45,8 @@ public: std::chrono::seconds TimestampSeconds; + std::chrono::milliseconds millis; + if (m_UseFullDate) { TimestampSeconds = std::chrono::duration_cast<std::chrono::seconds>(msg.time.time_since_epoch()); @@ -69,6 +71,8 @@ public: spdlog::details::fmt_helper::pad2(m_CachedLocalTm.tm_sec, m_CachedDatetime); m_CachedDatetime.push_back('.'); } + + millis = spdlog::details::fmt_helper::time_fraction<std::chrono::milliseconds>(msg.time); } else { @@ -97,6 +101,8 @@ public: spdlog::details::fmt_helper::pad2(LogSecs, m_CachedDatetime); m_CachedDatetime.push_back('.'); } + + millis = std::chrono::duration_cast<std::chrono::milliseconds>(ElapsedTime - TimestampSeconds); } { @@ -104,7 +110,6 @@ public: OutBuffer.append(m_CachedDatetime.begin(), m_CachedDatetime.end()); } - auto millis = spdlog::details::fmt_helper::time_fraction<std::chrono::milliseconds>(msg.time); spdlog::details::fmt_helper::pad3(static_cast<uint32_t>(millis.count()), OutBuffer); OutBuffer.push_back(']'); OutBuffer.push_back(' '); |