From e2e5f5cd9da7d5a4d54a8c3fb3981ba82accc78e Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Wed, 16 Mar 2011 15:42:04 -0400 Subject: Fix -logtimestamps to only print time prefix once per output line Incorporate BlueMatt's fix to only timestamp upon new line, and move -logtimestamp checking outside OutputDebugPrintF() to better future-proof it. --- util.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'util.cpp') diff --git a/util.cpp b/util.cpp index 26f8e0ac2..655626dd3 100644 --- a/util.cpp +++ b/util.cpp @@ -19,6 +19,7 @@ bool fCommandLine = false; string strMiscWarning; bool fTestNet = false; bool fNoListen = false; +bool fLogTimestamps = false; @@ -170,9 +171,16 @@ inline int OutputDebugStringF(const char* pszFormat, ...) } if (fileout) { + static bool fStartedNewLine = true; + // Debug print useful for profiling - if (GetBoolArg("-logtimestamps")) + if (fLogTimestamps && fStartedNewLine) fprintf(fileout, "%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str()); + if (pszFormat[strlen(pszFormat) - 1] == '\n') + fStartedNewLine = true; + else + fStartedNewLine = false; + va_list arg_ptr; va_start(arg_ptr, pszFormat); ret = vfprintf(fileout, pszFormat, arg_ptr); -- cgit v1.2.3