Browse Source

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`.
0.10
Wladimir J. van der Laan 11 years ago
parent
commit
96ff9d6403
  1. 4
      src/chainparamsbase.cpp
  2. 6
      src/chainparamsbase.h
  3. 2
      src/util.cpp

4
src/chainparamsbase.cpp

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

6
src/chainparamsbase.h

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

2
src/util.cpp

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

Loading…
Cancel
Save