Skip to content

Commit

Permalink
[Core] Add -debugexclude option
Browse files Browse the repository at this point in the history
to switch off logging for specified components
Backports bitcoin/bitcoin@3bde556
  • Loading branch information
random-zebra committed Mar 20, 2020
1 parent 884edb3 commit 8f2a7a9
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ std::string HelpMessage(HelpMessageMode mode)
}
strUsage += HelpMessageOpt("-debug=<category>", strprintf(_("Output debugging information (default: %u, supplying <category> is optional)"), 0) + ". " +
_("If <category> is not supplied, output all debugging information.") + _("<category> can be:") + " " + ListLogCategories() + ".");
strUsage += HelpMessageOpt("-debugexclude=<category>", _("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 (GetBoolArg("-help-debug", false))
strUsage += HelpMessageOpt("-nodebug", "Turn off debugging messages, same as -debug=0");
#ifdef ENABLE_WALLET
Expand Down Expand Up @@ -954,12 +955,24 @@ bool AppInit2()
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<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
if (GetBoolArg("-debugnet", false))
InitWarning(_("Warning: Unsupported argument -debugnet ignored, use -debug=net."));
Expand Down

0 comments on commit 8f2a7a9

Please sign in to comment.