From 981efed749556fa707282c065ca32200a7d92ed7 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Fri, 25 Mar 2016 02:15:03 +0300 Subject: [PATCH] Few debug related fixes - make logthreadnames work correctly without logtimestamps (and with emty strings again) - fix crash in debug (it3) - log debug info about locks in one line - show actual DS rounds instead of n/a in coin control while in debug mode - fix initial string in debug.log: "Bitcoin version" -> "Dash version" --- src/init.cpp | 4 ++-- src/masternodeman.cpp | 2 +- src/qt/coincontroldialog.cpp | 2 +- src/sync.cpp | 3 +-- src/util.cpp | 14 +++++++------- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index c3838a2f41..c5d817a5c7 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -875,7 +875,7 @@ void InitLogging() fLogIPs = GetBoolArg("-logips", DEFAULT_LOGIPS); LogPrintf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); - LogPrintf("Bitcoin version %s (%s)\n", FormatFullVersion(), CLIENT_DATE); + LogPrintf("Dash version %s (%s)\n", FormatFullVersion(), CLIENT_DATE); } /** Initialize dash. @@ -1702,7 +1702,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) pwalletMain->SetBestChain(chainActive.GetLocator()); } - if(!strErrors.str().empty()) LogPrintf("%s", strErrors.str()); + LogPrintf("%s", strErrors.str()); LogPrintf(" wallet %15dms\n", GetTimeMillis() - nStart); RegisterValidationInterface(pwalletMain); diff --git a/src/masternodeman.cpp b/src/masternodeman.cpp index f129ea0f57..5c1d97a750 100644 --- a/src/masternodeman.cpp +++ b/src/masternodeman.cpp @@ -342,7 +342,7 @@ void CMasternodeMan::CheckAndRemove(bool forceExpiredRemoval) map::iterator it4 = mapSeenMasternodePing.begin(); while(it4 != mapSeenMasternodePing.end()){ if((*it4).second.sigTime < GetTime() - MASTERNODE_REMOVAL_SECONDS*2){ - LogPrint("masternode", "CMasternodeMan::CheckAndRemove - Removing expired Masternode ping %s\n", (*it3).second.GetHash().ToString()); + LogPrint("masternode", "CMasternodeMan::CheckAndRemove - Removing expired Masternode ping %s\n", (*it4).second.GetHash().ToString()); mapSeenMasternodePing.erase(it4++); } else { ++it4; diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp index 59e84be25e..5e2948381d 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -845,7 +845,7 @@ void CoinControlDialog::updateView() CTxIn vin = CTxIn(out.tx->GetHash(), out.i); int rounds = pwalletMain->GetInputDarksendRounds(vin); - if(rounds >= 0) itemOutput->setText(COLUMN_DARKSEND_ROUNDS, strPad(QString::number(rounds), 11, " ")); + if(rounds >= 0 || fDebug) itemOutput->setText(COLUMN_DARKSEND_ROUNDS, strPad(QString::number(rounds), 11, " ")); else itemOutput->setText(COLUMN_DARKSEND_ROUNDS, strPad(QString(tr("n/a")), 11, " ")); diff --git a/src/sync.cpp b/src/sync.cpp index 8df8ae43f4..b7f0883502 100644 --- a/src/sync.cpp +++ b/src/sync.cpp @@ -15,8 +15,7 @@ #ifdef DEBUG_LOCKCONTENTION void PrintLockContention(const char* pszName, const char* pszFile, int nLine) { - LogPrintf("LOCKCONTENTION: %s\n", pszName); - LogPrintf("Locker: %s:%d\n", pszFile, nLine); + LogPrintf("LOCKCONTENTION: %s Locker: %s:%d\n", pszName, pszFile, nLine); } #endif /* DEBUG_LOCKCONTENTION */ diff --git a/src/util.cpp b/src/util.cpp index 1b82ea160b..c955592d6d 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -300,7 +300,7 @@ bool LogAcceptCategory(const char* category) /** * fStartedNewLine is a state variable held by the calling context that will * suppress printing of the timestamp when multiple calls are made that don't - * end in a newline. Initialize it to true, and hold it, in the calling context. + * end in a newline. Initialize it to true, and hold/manage it, in the calling context. */ static std::string LogTimestampStr(const std::string &str, bool *fStartedNewLine) { @@ -318,18 +318,13 @@ static std::string LogTimestampStr(const std::string &str, bool *fStartedNewLine } else strStamped = str; - if (!str.empty() && str[str.size()-1] == '\n') - *fStartedNewLine = true; - else - *fStartedNewLine = false; - return strStamped; } /** * fStartedNewLine is a state variable held by the calling context that will * suppress printing of the thread name when multiple calls are made that don't - * end in a newline. Initialize it to true, and hold it, in the calling context. + * end in a newline. Initialize it to true, and hold/manage it, in the calling context. */ static std::string LogThreadNameStr(const std::string &str, bool *fStartedNewLine) { @@ -356,6 +351,11 @@ int LogPrintStr(const std::string &str) std::string strThreadLogged = LogThreadNameStr(str, &fStartedNewLine); std::string strTimestamped = LogTimestampStr(strThreadLogged, &fStartedNewLine); + if (!str.empty() && str[str.size()-1] == '\n') + fStartedNewLine = true; + else + fStartedNewLine = false; + if (fPrintToConsole) { // print to console