aboutsummaryrefslogtreecommitdiff
path: root/src/util.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <[email protected]>2015-10-26 21:04:33 +0100
committerWladimir J. van der Laan <[email protected]>2015-10-26 21:04:41 +0100
commit2b625510d37471d4eaf5f99c2311afbdcae448c2 (patch)
tree77cd9b5aaeefcd75409dab1811a7b6985744276b /src/util.cpp
parentMerge pull request #6622 (diff)
parentAdd option for microsecond precision in debug.log (diff)
downloaddiscoin-2b625510d37471d4eaf5f99c2311afbdcae448c2.tar.xz
discoin-2b625510d37471d4eaf5f99c2311afbdcae448c2.zip
Merge pull request #6881
7bbc7c3 Add option for microsecond precision in debug.log (Suhas Daftuar)
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 8192a7c71..e8514a2ef 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')