Debug logging changes

Don’t write out logs by default unless you are using -server or -daemon
flags
Write debug logs out if you specify the -debuglog flag
Do not write debug logs out if you specify -nodebuglog
Write debug logs out if you specify -debug (overrides all other options)
This commit is contained in:
Alan Westbrook 2014-01-30 01:28:43 -08:00
parent 4075147917
commit 87f599d648
4 changed files with 16 additions and 1 deletions

View file

@ -341,6 +341,7 @@ std::string HelpMessage()
" -daemon " + _("Run in the background as a daemon and accept commands") + "\n" +
#endif
" -testnet " + _("Use the test network") + "\n" +
" -debuglog " + +("Write out the debug.log file") + "\n" +
" -debug " + _("Output extra debugging information. Implies all other -debug* options") + "\n" +
" -debugnet " + _("Output extra network debugging information") + "\n" +
" -logtimestamps " + _("Prepend debug output with timestamp (default: 1)") + "\n" +
@ -554,6 +555,8 @@ bool AppInit2(boost::thread_group& threadGroup)
// ********************************************************* Step 3: parameter-to-internal-flags
fDebug = GetBoolArg("-debug");
bool defaultWriteToLog = GetBoolArg("-server") || GetBoolArg("-daemon");
fWriteDebugLog = fDebug ? fDebug : GetBoolArg("-debuglog", defaultWriteToLog);
fBenchmark = GetBoolArg("-benchmark");
// -par=0 means autodetect, but nScriptCheckThreads==0 means no concurrency

View file

@ -267,6 +267,13 @@ bool isObscured(QWidget *w)
void openDebugLogfile()
{
// If we are opening it, might as well fire up debugging for this session.
if ( ! fWriteDebugLog )
{
fWriteDebugLog = true;
OutputDebugStringF("Starting debug session");
}
boost::filesystem::path pathDebug = GetDataDir() / "debug.log";
/* Open debug.log with the associated application */

View file

@ -69,10 +69,12 @@ namespace boost {
using namespace std;
// Seriously? Global hell.
map<string, string> mapArgs;
map<string, vector<string> > mapMultiArgs;
bool fDebug = false;
bool fDebugNet = false;
bool fWriteDebugLog = false;
bool fPrintToConsole = false;
bool fPrintToDebugger = false;
bool fDaemon = false;
@ -237,6 +239,8 @@ static void DebugPrintInit()
int OutputDebugStringF(const char* pszFormat, ...)
{
if ( ! fWriteDebugLog ) return 0;
int ret = 0; // Returns total number of characters written
if (fPrintToConsole)
{
@ -246,7 +250,7 @@ int OutputDebugStringF(const char* pszFormat, ...)
ret += vprintf(pszFormat, arg_ptr);
va_end(arg_ptr);
}
else if (!fPrintToDebugger)
else if (!fPrintToDebugger && fWriteDebugLog )
{
static bool fStartedNewLine = true;
boost::call_once(&DebugPrintInit, debugPrintInitFlag);

View file

@ -138,6 +138,7 @@ extern std::map<std::string, std::string> mapArgs;
extern std::map<std::string, std::vector<std::string> > mapMultiArgs;
extern bool fDebug;
extern bool fDebugNet;
extern bool fWriteDebugLog;
extern bool fPrintToConsole;
extern bool fPrintToDebugger;
extern bool fDaemon;