Can't log to debug log before chain params initialized

Add a function `AreBaseParamsConfigured` and use this to check
before writing to the debug log. This avoids assertions when the
application happens to log too early, which happens in the GUI.

Messages logged before the base parameters are configured can be
shown using `-printtoconsole`.
This commit is contained in:
Wladimir J. van der Laan 2014-07-15 10:22:27 +02:00
parent 2c0f019bfc
commit 96ff9d6403
3 changed files with 11 additions and 1 deletions

View File

@ -91,3 +91,7 @@ bool SelectBaseParamsFromCommandLine() {
}
return true;
}
bool AreBaseParamsConfigured() {
return pCurrentBaseParams != NULL;
}

View File

@ -49,4 +49,10 @@ void SelectBaseParams(CBaseChainParams::Network network);
*/
bool SelectBaseParamsFromCommandLine();
/**
* Return true if SelectBaseParamsFromCommandLine() has been called to select
* a network.
*/
bool AreBaseParamsConfigured();
#endif

View File

@ -205,7 +205,7 @@ int LogPrintStr(const std::string &str)
// print to console
ret = fwrite(str.data(), 1, str.size(), stdout);
}
else if (fPrintToDebugLog)
else if (fPrintToDebugLog && AreBaseParamsConfigured())
{
static bool fStartedNewLine = true;
boost::call_once(&DebugPrintInit, debugPrintInitFlag);