mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Add real timestamp to log output when mock time is enabled (#2604)
* Implement IsMockTime to test for mock time * Add real timestamp to log output when mock time is enabled This makes debugging on Travis easier as it gives a hint about timing behavior.
This commit is contained in:
parent
0648496e21
commit
968eb3fc5d
@ -316,8 +316,12 @@ static std::string LogTimestampStr(const std::string &str, std::atomic_bool *fSt
|
||||
return str;
|
||||
|
||||
if (*fStartedNewLine) {
|
||||
if (IsMockTime()) {
|
||||
int64_t nRealTimeMicros = GetTimeMicros();
|
||||
strStamped = DateTimeStrFormat("(real %Y-%m-%d %H:%M:%S) ", nRealTimeMicros/1000000);
|
||||
}
|
||||
int64_t nTimeMicros = GetLogTimeMicros();
|
||||
strStamped = DateTimeStrFormat("%Y-%m-%d %H:%M:%S", nTimeMicros/1000000);
|
||||
strStamped += DateTimeStrFormat("%Y-%m-%d %H:%M:%S", nTimeMicros/1000000);
|
||||
if (fLogTimeMicros)
|
||||
strStamped += strprintf(".%06d", nTimeMicros%1000000);
|
||||
strStamped += ' ' + str;
|
||||
|
@ -29,6 +29,11 @@ void SetMockTime(int64_t nMockTimeIn)
|
||||
nMockTime = nMockTimeIn;
|
||||
}
|
||||
|
||||
bool IsMockTime()
|
||||
{
|
||||
return nMockTime != 0;
|
||||
}
|
||||
|
||||
int64_t GetTimeMillis()
|
||||
{
|
||||
int64_t now = (boost::posix_time::microsec_clock::universal_time() -
|
||||
|
@ -25,6 +25,7 @@ int64_t GetTimeMicros();
|
||||
int64_t GetSystemTimeInSeconds(); // Like GetTime(), but not mockable
|
||||
int64_t GetLogTimeMicros();
|
||||
void SetMockTime(int64_t nMockTimeIn);
|
||||
bool IsMockTime();
|
||||
void MilliSleep(int64_t n);
|
||||
|
||||
std::string DateTimeStrFormat(const char* pszFormat, int64_t nTime);
|
||||
|
Loading…
Reference in New Issue
Block a user