Browse Source

Merge pull request #3067 from Diapolo/debug-switch

re-work -debug switch handling
0.10
Gavin Andresen 11 years ago
parent
commit
ef4b518aea
  1. 4
      src/addrman.h
  2. 31
      src/init.cpp
  3. 6
      src/main.cpp
  4. 1
      src/qt/paymentrequestplus.cpp
  5. 6
      src/qt/paymentserver.cpp
  6. 13
      src/util.cpp
  7. 1
      src/util.h

4
src/addrman.h

@ -419,7 +419,7 @@ public: @@ -419,7 +419,7 @@ public:
Check();
}
if (fRet)
LogPrint("addr", "Added %s from %s: %i tried, %i new\n", addr.ToStringIPPort().c_str(), source.ToString().c_str(), nTried, nNew);
LogPrint("addrman", "Added %s from %s: %i tried, %i new\n", addr.ToStringIPPort().c_str(), source.ToString().c_str(), nTried, nNew);
return fRet;
}
@ -435,7 +435,7 @@ public: @@ -435,7 +435,7 @@ public:
Check();
}
if (nAdd)
LogPrint("addr", "Added %i addresses from %s: %i tried, %i new\n", nAdd, source.ToString().c_str(), nTried, nNew);
LogPrint("addrman", "Added %i addresses from %s: %i tried, %i new\n", nAdd, source.ToString().c_str(), nTried, nNew);
return nAdd > 0;
}

31
src/init.cpp

@ -215,8 +215,18 @@ std::string HelpMessage(HelpMessageMode hmm) @@ -215,8 +215,18 @@ std::string HelpMessage(HelpMessageMode hmm)
#endif
#endif
strUsage += " -paytxfee=<amt> " + _("Fee per KB to add to transactions you send") + "\n";
strUsage += " -debug " + _("Output extra debugging information. Implies all other -debug* options") + "\n";
strUsage += " -debugnet " + _("Output extra network debugging information") + "\n";
strUsage += " -debug=<category> " + _("Output debugging information (default: 0, supplying <category> is optional)") + "\n";
strUsage += _("If <category> is not supplied, output all debugging information.") + "\n";
strUsage += _("<category> can be:");
strUsage += " addrman, alert, coindb, db, lock, rand, rpc, selectcoins, mempool, net"; // Don't translate these and qt below
if (hmm == HMM_BITCOIN_QT)
{
strUsage += ", qt.\n";
}
else
{
strUsage += ".\n";
}
strUsage += " -logtimestamps " + _("Prepend debug output with timestamp") + "\n";
strUsage += " -shrinkdebugfile " + _("Shrink debug.log file on client startup (default: 1 when no -debug)") + "\n";
strUsage += " -printtoconsole " + _("Send trace/debug info to console instead of debug.log file") + "\n";
@ -457,7 +467,16 @@ bool AppInit2(boost::thread_group& threadGroup) @@ -457,7 +467,16 @@ bool AppInit2(boost::thread_group& threadGroup)
// ********************************************************* Step 3: parameter-to-internal-flags
if (mapMultiArgs.count("-debug")) fDebug = true;
fDebug = !mapMultiArgs["-debug"].empty();
// Special-case: if -debug=0/-nodebug is set, turn off debugging messages
const vector<string>& categories = mapMultiArgs["-debug"];
if (GetBoolArg("-nodebug", false) || find(categories.begin(), categories.end(), string("0")) != categories.end())
fDebug = false;
// Check for -debugnet (deprecated)
if (GetBoolArg("-debugnet", false))
InitWarning(_("Warning: Deprecated argument -debugnet ignored, use -debug=net"));
fBenchmark = GetBoolArg("-benchmark", false);
mempool.fChecks = GetBoolArg("-checkmempool", RegTest());
Checkpoints::fEnabled = GetBoolArg("-checkpoints", true);
@ -471,12 +490,6 @@ bool AppInit2(boost::thread_group& threadGroup) @@ -471,12 +490,6 @@ bool AppInit2(boost::thread_group& threadGroup)
else if (nScriptCheckThreads > MAX_SCRIPTCHECK_THREADS)
nScriptCheckThreads = MAX_SCRIPTCHECK_THREADS;
// -debug implies fDebug*
if (fDebug)
fDebugNet = true;
else
fDebugNet = GetBoolArg("-debugnet", false);
if (fDaemon)
fServer = true;
else

6
src/main.cpp

@ -3544,10 +3544,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) @@ -3544,10 +3544,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
return error("message getdata size() = %"PRIszu"", vInv.size());
}
if (fDebugNet || (vInv.size() != 1))
if (fDebug || (vInv.size() != 1))
LogPrint("net", "received getdata (%"PRIszu" invsz)\n", vInv.size());
if ((fDebugNet && vInv.size() > 0) || (vInv.size() == 1))
if ((fDebug && vInv.size() > 0) || (vInv.size() == 1))
LogPrint("net", "received getdata for: %s\n", vInv[0].ToString().c_str());
pfrom->vRecvGetData.insert(pfrom->vRecvGetData.end(), vInv.begin(), vInv.end());
@ -4213,7 +4213,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) @@ -4213,7 +4213,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
const CInv& inv = (*pto->mapAskFor.begin()).second;
if (!AlreadyHave(inv))
{
if (fDebugNet)
if (fDebug)
LogPrint("net", "sending getdata: %s\n", inv.ToString().c_str());
vGetData.push_back(inv);
if (vGetData.size() >= 1000)

1
src/qt/paymentrequestplus.cpp

@ -75,7 +75,6 @@ bool PaymentRequestPlus::getMerchant(X509_STORE* certStore, QString& merchant) c @@ -75,7 +75,6 @@ bool PaymentRequestPlus::getMerchant(X509_STORE* certStore, QString& merchant) c
digestAlgorithm = EVP_sha1();
}
else if (paymentRequest.pki_type() == "none") {
if (fDebug)
qDebug() << "PaymentRequestPlus::getMerchant : Payment request: pki_type == none";
return false;
}

6
src/qt/paymentserver.cpp

@ -87,10 +87,8 @@ static QList<QString> savedPaymentRequests; @@ -87,10 +87,8 @@ static QList<QString> savedPaymentRequests;
static void ReportInvalidCertificate(const QSslCertificate& cert)
{
if (fDebug) {
qDebug() << "ReportInvalidCertificate : Payment server found an invalid certificate: " << cert.subjectInfo(QSslCertificate::CommonName);
}
}
//
// Load OpenSSL's list of root certificate authorities
@ -160,7 +158,6 @@ void PaymentServer::LoadRootCAs(X509_STORE* _store) @@ -160,7 +158,6 @@ void PaymentServer::LoadRootCAs(X509_STORE* _store)
continue;
}
}
if (fDebug)
qDebug() << "PaymentServer::LoadRootCAs : Loaded " << nRootCerts << " root certificates";
// Project for another day:
@ -375,7 +372,6 @@ void PaymentServer::handleURIOrFile(const QString& s) @@ -375,7 +372,6 @@ void PaymentServer::handleURIOrFile(const QString& s)
QString decoded = QUrl::fromPercentEncoding(temp);
QUrl fetchUrl(decoded, QUrl::StrictMode);
if (fDebug)
qDebug() << "PaymentServer::handleURIOrFile : fetchRequest(" << fetchUrl << ")";
if (fetchUrl.isValid())
@ -475,7 +471,6 @@ bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, QList<Sen @@ -475,7 +471,6 @@ bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, QList<Sen
if (request.getMerchant(PaymentServer::certStore, recipients[0].authenticatedMerchant)) {
recipients[0].paymentRequest = request;
recipients[0].amount = totalAmount;
if (fDebug)
qDebug() << "PaymentServer::processPaymentRequest : Payment request from " << recipients[0].authenticatedMerchant;
}
else {
@ -493,7 +488,6 @@ bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, QList<Sen @@ -493,7 +488,6 @@ bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, QList<Sen
if (i == 0) // Tie request to first pay-to, we don't want multiple ACKs
recipients[i].paymentRequest = request;
recipients[i].address = QString::fromStdString(CBitcoinAddress(dest).ToString());
if (fDebug)
qDebug() << "PaymentServer::processPaymentRequest : Payment request, insecure " << recipients[i].address;
}
else {

13
src/util.cpp

@ -73,7 +73,6 @@ using namespace std; @@ -73,7 +73,6 @@ using namespace std;
map<string, string> mapArgs;
map<string, vector<string> > mapMultiArgs;
bool fDebug = false;
bool fDebugNet = false;
bool fPrintToConsole = false;
bool fPrintToDebugger = false;
bool fDaemon = false;
@ -226,11 +225,21 @@ int LogPrint(const char* category, const char* pszFormat, ...) @@ -226,11 +225,21 @@ int LogPrint(const char* category, const char* pszFormat, ...)
{
if (category != NULL)
{
if (!fDebug) return 0;
if (!fDebug)
return 0;
const vector<string>& categories = mapMultiArgs["-debug"];
bool allCategories = count(categories.begin(), categories.end(), string(""));
// Only look for categories, if not -debug/-debug=1 was passed,
// as that implies every category should be logged.
if (!allCategories)
{
// Category was not found (not supplied via -debug=<category>)
if (find(categories.begin(), categories.end(), string(category)) == categories.end())
return 0;
}
}
int ret = 0; // Returns total number of characters written
if (fPrintToConsole)

1
src/util.h

@ -140,7 +140,6 @@ inline void MilliSleep(int64 n) @@ -140,7 +140,6 @@ inline void MilliSleep(int64 n)
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 fPrintToConsole;
extern bool fPrintToDebugger;
extern bool fDaemon;

Loading…
Cancel
Save