From 3bde5564294b36780d1839ed4aec4612fe3a69dd Mon Sep 17 00:00:00 2001 From: John Newbery Date: Sun, 2 Apr 2017 19:56:03 -0400 Subject: [PATCH] Add -debugexclude option to switch off logging for specified components --- src/init.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/init.cpp b/src/init.cpp index 23a15b4fd8..59e5a4a207 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -443,6 +443,7 @@ std::string HelpMessage(HelpMessageMode mode) } strUsage += HelpMessageOpt("-debug=", strprintf(_("Output debugging information (default: %u, supplying is optional)"), 0) + ". " + _("If is not supplied or if = 1, output all debugging information.") + " " + _(" can be:") + " " + ListLogCategories() + "."); + strUsage += HelpMessageOpt("-debugexclude=", 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) strUsage += HelpMessageOpt("-nodebug", "Turn off debugging messages, same as -debug=0"); strUsage += HelpMessageOpt("-help-debug", _("Show all debugging options (usage: --help -help-debug)")); @@ -914,13 +915,25 @@ bool AppInitParameterInteraction() for (const auto& cat : categories) { uint32_t flag; if (!GetLogCategory(&flag, &cat)) { - InitWarning(strprintf(_("Unsupported logging category %s.\n"), cat)); + InitWarning(strprintf(_("Unsupported logging category %s=%s."), "-debug", cat)); } logCategories |= flag; } } } + // Now remove the logging categories which were explicitly excluded + if (mapMultiArgs.count("-debugexclude") > 0) { + const std::vector& 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 if (GetBoolArg("-debugnet", false)) InitWarning(_("Unsupported argument -debugnet ignored, use -debug=net."));