aboutsummaryrefslogtreecommitdiff
path: root/src/util.cpp
diff options
context:
space:
mode:
authorSuhas Daftuar <sdaftuar@gmail.com>2015-10-23 13:07:36 -0400
committerSuhas Daftuar <sdaftuar@gmail.com>2015-10-26 15:05:37 -0400
commit7bbc7c314f4ebb1e7fe882a0a2aae5a5655f2972 (patch)
tree962a5af7cb1251b5166915474c80d4b54277fc52 /src/util.cpp
parentd78a880900c15c7a28ae81e6632090f25fea7fce (diff)
downloadbitcoin-7bbc7c314f4ebb1e7fe882a0a2aae5a5655f2972.tar.xz
Add option for microsecond precision in debug.log
Diffstat (limited to 'src/util.cpp')
-rw-r--r--src/util.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/util.cpp b/src/util.cpp
index 8192a7c71c..e8514a2ef0 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -108,6 +108,7 @@ bool fDaemon = false;
bool fServer = false;
string strMiscWarning;
bool fLogTimestamps = false;
+bool fLogTimeMicros = DEFAULT_LOGTIMEMICROS;
bool fLogIPs = false;
volatile bool fReopenDebugLog = false;
CTranslationInterface translationInterface;
@@ -263,9 +264,13 @@ static std::string LogTimestampStr(const std::string &str, bool *fStartedNewLine
if (!fLogTimestamps)
return str;
- if (*fStartedNewLine)
- strStamped = DateTimeStrFormat("%Y-%m-%d %H:%M:%S", GetTime()) + ' ' + str;
- else
+ if (*fStartedNewLine) {
+ int64_t nTimeMicros = GetLogTimeMicros();
+ strStamped = DateTimeStrFormat("%Y-%m-%d %H:%M:%S", nTimeMicros/1000000);
+ if (fLogTimeMicros)
+ strStamped += strprintf(".%06d", nTimeMicros%1000000);
+ strStamped += ' ' + str;
+ } else
strStamped = str;
if (!str.empty() && str[str.size()-1] == '\n')