diff --git a/src/logging.cpp b/src/logging.cpp index 298ec9c0139..a9b2a2b33a5 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -349,11 +349,12 @@ std::string BCLog::Logger::LogTimestampStr(const std::string& str) return str; if (m_started_new_line) { - int64_t nTimeMicros = GetTimeMicros(); - strStamped = FormatISO8601DateTime(nTimeMicros/1000000); + const auto now{SystemClock::now()}; + const auto now_seconds{std::chrono::time_point_cast(now)}; + strStamped = FormatISO8601DateTime(TicksSinceEpoch(now_seconds)); if (m_log_time_micros) { strStamped.pop_back(); - strStamped += strprintf(".%06dZ", nTimeMicros%1000000); + strStamped += strprintf(".%06dZ", Ticks(now - now_seconds)); } std::chrono::seconds mocktime = GetMockTime(); if (mocktime > 0s) { diff --git a/src/util/time.cpp b/src/util/time.cpp index 58200c83fcb..fb9bc349314 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -107,11 +107,6 @@ int64_t GetTimeMillis() return int64_t{GetSystemTime().count()}; } -int64_t GetTimeMicros() -{ - return int64_t{GetSystemTime().count()}; -} - int64_t GetTime() { return GetTime().count(); } std::string FormatISO8601DateTime(int64_t nTime) { diff --git a/src/util/time.h b/src/util/time.h index fcf85c1e039..8c6baeb12a7 100644 --- a/src/util/time.h +++ b/src/util/time.h @@ -29,6 +29,8 @@ using SteadySeconds = std::chrono::time_point; using SteadyMicroseconds = std::chrono::time_point; +using SystemClock = std::chrono::system_clock; + void UninterruptibleSleep(const std::chrono::microseconds& n); /** @@ -63,16 +65,14 @@ using MillisecondsDouble = std::chrono::duration() if a cast is needed. * ClockType is - * - std::chrono::steady_clock for steady time - * - std::chrono::system_clock for system time - * - NodeClock for mockable system time + * - SteadyClock/std::chrono::steady_clock for steady time + * - SystemClock/std::chrono::system_clock for system time + * - NodeClock for mockable system time */ int64_t GetTime(); /** Returns the system time (not mockable) */ int64_t GetTimeMillis(); -/** Returns the system time (not mockable) */ -int64_t GetTimeMicros(); /** * DEPRECATED