Add -debugexclude option to switch off logging for specified components

This commit is contained in:
John Newbery 2017-04-02 19:56:03 -04:00
parent ebfd653798
commit 3bde556429

View file

@ -443,6 +443,7 @@ std::string HelpMessage(HelpMessageMode mode)
} }
strUsage += HelpMessageOpt("-debug=<category>", strprintf(_("Output debugging information (default: %u, supplying <category> is optional)"), 0) + ". " + strUsage += HelpMessageOpt("-debug=<category>", strprintf(_("Output debugging information (default: %u, supplying <category> is optional)"), 0) + ". " +
_("If <category> is not supplied or if <category> = 1, output all debugging information.") + " " + _("<category> can be:") + " " + ListLogCategories() + "."); _("If <category> is not supplied or if <category> = 1, output all debugging information.") + " " + _("<category> can be:") + " " + ListLogCategories() + ".");
strUsage += HelpMessageOpt("-debugexclude=<category>", strprintf(_("Exclude debugging information for a category. Can be used in conjunction with -debug=1 to output debug logs for all categories except one or more specified categories.")));
if (showDebug) if (showDebug)
strUsage += HelpMessageOpt("-nodebug", "Turn off debugging messages, same as -debug=0"); strUsage += HelpMessageOpt("-nodebug", "Turn off debugging messages, same as -debug=0");
strUsage += HelpMessageOpt("-help-debug", _("Show all debugging options (usage: --help -help-debug)")); strUsage += HelpMessageOpt("-help-debug", _("Show all debugging options (usage: --help -help-debug)"));
@ -914,13 +915,25 @@ bool AppInitParameterInteraction()
for (const auto& cat : categories) { for (const auto& cat : categories) {
uint32_t flag; uint32_t flag;
if (!GetLogCategory(&flag, &cat)) { if (!GetLogCategory(&flag, &cat)) {
InitWarning(strprintf(_("Unsupported logging category %s.\n"), cat)); InitWarning(strprintf(_("Unsupported logging category %s=%s."), "-debug", cat));
} }
logCategories |= flag; logCategories |= flag;
} }
} }
} }
// Now remove the logging categories which were explicitly excluded
if (mapMultiArgs.count("-debugexclude") > 0) {
const std::vector<std::string>& excludedCategories = mapMultiArgs.at("-debugexclude");
for (const auto& cat : excludedCategories) {
uint32_t flag;
if (!GetLogCategory(&flag, &cat)) {
InitWarning(strprintf(_("Unsupported logging category %s=%s."), "-debugexclude", cat));
}
logCategories &= ~flag;
}
}
// Check for -debugnet // Check for -debugnet
if (GetBoolArg("-debugnet", false)) if (GetBoolArg("-debugnet", false))
InitWarning(_("Unsupported argument -debugnet ignored, use -debug=net.")); InitWarning(_("Unsupported argument -debugnet ignored, use -debug=net."));