diff --git a/src/logging.cpp b/src/logging.cpp --- a/src/logging.cpp +++ b/src/logging.cpp @@ -142,12 +142,18 @@ } if (m_started_new_line) { - int64_t nTimeMicros = GetLogTimeMicros(); + int64_t nTimeMicros = GetTimeMicros(); strStamped = DateTimeStrFormat("%Y-%m-%d %H:%M:%S", nTimeMicros / 1000000); if (m_log_time_micros) { strStamped += strprintf(".%06d", nTimeMicros % 1000000); } + int64_t mocktime = GetMockTime(); + if (mocktime) { + strStamped += " (mocktime: " + + DateTimeStrFormat("%Y-%m-%d %H:%M:%S", mocktime) + + ")"; + } strStamped += ' ' + str; } else { strStamped = str; diff --git a/src/utiltime.h b/src/utiltime.h --- a/src/utiltime.h +++ b/src/utiltime.h @@ -24,8 +24,8 @@ int64_t GetTimeMicros(); // Like GetTime(), but not mockable int64_t GetSystemTimeInSeconds(); -int64_t GetLogTimeMicros(); void SetMockTime(int64_t nMockTimeIn); +int64_t GetMockTime(); void MilliSleep(int64_t n); std::string DateTimeStrFormat(const char *pszFormat, int64_t nTime); diff --git a/src/utiltime.cpp b/src/utiltime.cpp --- a/src/utiltime.cpp +++ b/src/utiltime.cpp @@ -32,6 +32,10 @@ nMockTime.store(nMockTimeIn, std::memory_order_relaxed); } +int64_t GetMockTime() { + return nMockTime.load(std::memory_order_relaxed); +} + int64_t GetTimeMillis() { int64_t now = (boost::posix_time::microsec_clock::universal_time() - boost::posix_time::ptime(boost::gregorian::date(1970, 1, 1))) @@ -52,16 +56,6 @@ return GetTimeMicros() / 1000000; } -/** Return a time useful for the debug log */ -int64_t GetLogTimeMicros() { - int64_t mocktime = nMockTime.load(std::memory_order_relaxed); - if (mocktime) { - return mocktime * 1000000; - } - - return GetTimeMicros(); -} - void MilliSleep(int64_t n) { boost::this_thread::sleep_for(boost::chrono::milliseconds(n)); }