mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-11 12:22:39 -03:00
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.
This commit is contained in:
parent
27b7f3b43a
commit
e2e5f5cd9d
3 changed files with 11 additions and 2 deletions
2
init.cpp
2
init.cpp
|
@ -211,8 +211,8 @@ bool AppInit2(int argc, char* argv[])
|
||||||
fPrintToDebugger = GetBoolArg("-printtodebugger");
|
fPrintToDebugger = GetBoolArg("-printtodebugger");
|
||||||
|
|
||||||
fTestNet = GetBoolArg("-testnet");
|
fTestNet = GetBoolArg("-testnet");
|
||||||
|
|
||||||
fNoListen = GetBoolArg("-nolisten");
|
fNoListen = GetBoolArg("-nolisten");
|
||||||
|
fLogTimestamps = GetBoolArg("-logtimestamps");
|
||||||
|
|
||||||
for (int i = 1; i < argc; i++)
|
for (int i = 1; i < argc; i++)
|
||||||
if (!IsSwitchChar(argv[i][0]))
|
if (!IsSwitchChar(argv[i][0]))
|
||||||
|
|
10
util.cpp
10
util.cpp
|
@ -19,6 +19,7 @@ bool fCommandLine = false;
|
||||||
string strMiscWarning;
|
string strMiscWarning;
|
||||||
bool fTestNet = false;
|
bool fTestNet = false;
|
||||||
bool fNoListen = false;
|
bool fNoListen = false;
|
||||||
|
bool fLogTimestamps = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -170,9 +171,16 @@ inline int OutputDebugStringF(const char* pszFormat, ...)
|
||||||
}
|
}
|
||||||
if (fileout)
|
if (fileout)
|
||||||
{
|
{
|
||||||
|
static bool fStartedNewLine = true;
|
||||||
|
|
||||||
// Debug print useful for profiling
|
// Debug print useful for profiling
|
||||||
if (GetBoolArg("-logtimestamps"))
|
if (fLogTimestamps && fStartedNewLine)
|
||||||
fprintf(fileout, "%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());
|
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_list arg_ptr;
|
||||||
va_start(arg_ptr, pszFormat);
|
va_start(arg_ptr, pszFormat);
|
||||||
ret = vfprintf(fileout, pszFormat, arg_ptr);
|
ret = vfprintf(fileout, pszFormat, arg_ptr);
|
||||||
|
|
1
util.h
1
util.h
|
@ -148,6 +148,7 @@ extern bool fCommandLine;
|
||||||
extern string strMiscWarning;
|
extern string strMiscWarning;
|
||||||
extern bool fTestNet;
|
extern bool fTestNet;
|
||||||
extern bool fNoListen;
|
extern bool fNoListen;
|
||||||
|
extern bool fLogTimestamps;
|
||||||
|
|
||||||
void RandAddSeed();
|
void RandAddSeed();
|
||||||
void RandAddSeedPerfmon();
|
void RandAddSeedPerfmon();
|
||||||
|
|
Loading…
Reference in a new issue