Changeset View
Changeset View
Standalone View
Standalone View
src/logging.cpp
Show First 20 Lines • Show All 136 Lines • ▼ Show 20 Lines | |||||
std::string BCLog::Logger::LogTimestampStr(const std::string &str) { | std::string BCLog::Logger::LogTimestampStr(const std::string &str) { | ||||
std::string strStamped; | std::string strStamped; | ||||
if (!m_log_timestamps) { | if (!m_log_timestamps) { | ||||
return str; | return str; | ||||
} | } | ||||
if (m_started_new_line) { | if (m_started_new_line) { | ||||
int64_t nTimeMicros = GetLogTimeMicros(); | int64_t nTimeMicros = GetTimeMicros(); | ||||
strStamped = | strStamped = | ||||
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", nTimeMicros / 1000000); | DateTimeStrFormat("%Y-%m-%d %H:%M:%S", nTimeMicros / 1000000); | ||||
if (m_log_time_micros) { | if (m_log_time_micros) { | ||||
strStamped += strprintf(".%06d", nTimeMicros % 1000000); | strStamped += strprintf(".%06d", nTimeMicros % 1000000); | ||||
} | } | ||||
int64_t mocktime = GetMockTime(); | |||||
if (mocktime) { | |||||
strStamped += " (mocktime: " + | |||||
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", mocktime) + | |||||
")"; | |||||
} | |||||
strStamped += ' ' + str; | strStamped += ' ' + str; | ||||
} else { | } else { | ||||
strStamped = str; | strStamped = str; | ||||
} | } | ||||
if (!str.empty() && str[str.size() - 1] == '\n') { | if (!str.empty() && str[str.size() - 1] == '\n') { | ||||
m_started_new_line = true; | m_started_new_line = true; | ||||
} else { | } else { | ||||
▲ Show 20 Lines • Show All 107 Lines • Show Last 20 Lines |