|
|
@ -242,18 +242,24 @@ int LogPrint(const char* category, const char* pszFormat, ...) |
|
|
|
if (!fDebug) |
|
|
|
if (!fDebug) |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Give each thread quick access to -debug settings.
|
|
|
|
|
|
|
|
// This helps prevent issues debugging global destructors,
|
|
|
|
|
|
|
|
// where mapMultiArgs might be deleted before another
|
|
|
|
|
|
|
|
// global destructor calls LogPrint()
|
|
|
|
|
|
|
|
static boost::thread_specific_ptr<set<string> > ptrCategory; |
|
|
|
|
|
|
|
if (ptrCategory.get() == NULL) |
|
|
|
|
|
|
|
{ |
|
|
|
const vector<string>& categories = mapMultiArgs["-debug"]; |
|
|
|
const vector<string>& categories = mapMultiArgs["-debug"]; |
|
|
|
bool allCategories = count(categories.begin(), categories.end(), string("")); |
|
|
|
ptrCategory.reset(new set<string>(categories.begin(), categories.end())); |
|
|
|
|
|
|
|
// thread_specific_ptr automatically deletes the set when the thread ends.
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const set<string>& setCategories = *ptrCategory.get(); |
|
|
|
|
|
|
|
|
|
|
|
// Only look for categories, if not -debug/-debug=1 was passed,
|
|
|
|
// if not debugging everything and not debugging specific category, LogPrint does nothing.
|
|
|
|
// as that implies every category should be logged.
|
|
|
|
if (setCategories.count(string("")) == 0 && |
|
|
|
if (!allCategories) |
|
|
|
setCategories.count(string(category)) == 0) |
|
|
|
{ |
|
|
|
|
|
|
|
// Category was not found (not supplied via -debug=<category>)
|
|
|
|
|
|
|
|
if (find(categories.begin(), categories.end(), string(category)) == categories.end()) |
|
|
|
|
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int ret = 0; // Returns total number of characters written
|
|
|
|
int ret = 0; // Returns total number of characters written
|
|
|
|
if (fPrintToConsole) |
|
|
|
if (fPrintToConsole) |
|
|
|