Changeset View
Changeset View
Standalone View
Standalone View
src/logging.cpp
Show First 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | 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 = GetTimeMicros(); | int64_t nTimeMicros = GetTimeMicros(); | ||||
strStamped = | strStamped = FormatISO8601DateTime(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(); | int64_t mocktime = GetMockTime(); | ||||
if (mocktime) { | if (mocktime) { | ||||
strStamped += " (mocktime: " + | strStamped += | ||||
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", mocktime) + | " (mocktime: " + FormatISO8601DateTime(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; | ||||
▲ Show 20 Lines • Show All 108 Lines • Show Last 20 Lines |