re-work -debug switch handling

- re-work -debug help message text
- make -debug log every debugging information again (even all categories)
- remove unneeded fDebug checks in front of LogPrint()/qDebug(), as that
  check is done in LogPrintf() when category is != NULL (true for all
  LogPrint() calls
- remove fDebug ONLY in code which is NOT performance-critical
- harmonize addrman category name
- deprecate -debugnet usage, should be used via -debug=net and remove the
  corresponding global
This commit is contained in:
Philip Kaufmann
2013-10-08 12:09:40 +02:00
parent 42a12f22d6
commit 3b570559f8
7 changed files with 46 additions and 32 deletions

View File

@@ -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,10 +225,20 @@ int LogPrint(const char* category, const char* pszFormat, ...)
{
if (category != NULL)
{
if (!fDebug) return 0;
const vector<string>& categories = mapMultiArgs["-debug"];
if (find(categories.begin(), categories.end(), string(category)) == categories.end())
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