Skip to content

Commit 471ed00

Browse files
committed
Merge #10123: Allow debug logs to be excluded from specified component
3bde556 Add -debugexclude option to switch off logging for specified components (John Newbery) Tree-SHA512: 30202e3f2085fc2fc5dd4bedb92988f4cb162c612a42cf8f6395a7da326f34975ddc347f82bc4ddca6c84c438dc0cc6e87869f90c7ff88105dbeaa52a947fa43
2 parents cb598cf + 3bde556 commit 471ed00

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/init.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ std::string HelpMessage(HelpMessageMode mode)
443443
}
444444
strUsage += HelpMessageOpt("-debug=<category>", strprintf(_("Output debugging information (default: %u, supplying <category> is optional)"), 0) + ". " +
445445
_("If <category> is not supplied or if <category> = 1, output all debugging information.") + " " + _("<category> can be:") + " " + ListLogCategories() + ".");
446+
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.")));
446447
if (showDebug)
447448
strUsage += HelpMessageOpt("-nodebug", "Turn off debugging messages, same as -debug=0");
448449
strUsage += HelpMessageOpt("-help-debug", _("Show all debugging options (usage: --help -help-debug)"));
@@ -914,13 +915,25 @@ bool AppInitParameterInteraction()
914915
for (const auto& cat : categories) {
915916
uint32_t flag;
916917
if (!GetLogCategory(&flag, &cat)) {
917-
InitWarning(strprintf(_("Unsupported logging category %s.\n"), cat));
918+
InitWarning(strprintf(_("Unsupported logging category %s=%s."), "-debug", cat));
918919
}
919920
logCategories |= flag;
920921
}
921922
}
922923
}
923924

925+
// Now remove the logging categories which were explicitly excluded
926+
if (mapMultiArgs.count("-debugexclude") > 0) {
927+
const std::vector<std::string>& excludedCategories = mapMultiArgs.at("-debugexclude");
928+
for (const auto& cat : excludedCategories) {
929+
uint32_t flag;
930+
if (!GetLogCategory(&flag, &cat)) {
931+
InitWarning(strprintf(_("Unsupported logging category %s=%s."), "-debugexclude", cat));
932+
}
933+
logCategories &= ~flag;
934+
}
935+
}
936+
924937
// Check for -debugnet
925938
if (GetBoolArg("-debugnet", false))
926939
InitWarning(_("Unsupported argument -debugnet ignored, use -debug=net."));

0 commit comments

Comments
 (0)