diff options
author | Jon Atack <jon@atack.com> | 2023-05-12 00:23:21 +0200 |
---|---|---|
committer | Jon Atack <jon@atack.com> | 2023-06-14 08:27:46 -0600 |
commit | 4c3c19d943a0a4cf191495f6ebe9b964835607a4 (patch) | |
tree | 6e617860dbaca0735cb769c3c9ecf5337831336f /src/init | |
parent | 681ecac5c2d462920cd32636eec15599a9bcf424 (diff) | |
download | bitcoin-4c3c19d943a0a4cf191495f6ebe9b964835607a4.tar.xz |
init: raise on invalid debug/debugexclude config options
Diffstat (limited to 'src/init')
-rw-r--r-- | src/init/common.cpp | 8 | ||||
-rw-r--r-- | src/init/common.h | 4 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/init/common.cpp b/src/init/common.cpp index 9a52a09cea..2c36d30fdf 100644 --- a/src/init/common.cpp +++ b/src/init/common.cpp @@ -13,6 +13,7 @@ #include <tinyformat.h> #include <util/fs.h> #include <util/fs_helpers.h> +#include <util/result.h> #include <util/string.h> #include <util/time.h> #include <util/translation.h> @@ -78,7 +79,7 @@ void SetLoggingLevel(const ArgsManager& args) } } -void SetLoggingCategories(const ArgsManager& args) +util::Result<void> SetLoggingCategories(const ArgsManager& args) { if (args.IsArgSet("-debug")) { // Special-case: if -debug=0/-nodebug is set, turn off debugging messages @@ -88,7 +89,7 @@ void SetLoggingCategories(const ArgsManager& args) [](std::string cat){return cat == "0" || cat == "none";})) { for (const auto& cat : categories) { if (!LogInstance().EnableCategory(cat)) { - InitWarning(strprintf(_("Unsupported logging category %s=%s."), "-debug", cat)); + return util::Error{strprintf(_("Unsupported logging category %s=%s."), "-debug", cat)}; } } } @@ -97,9 +98,10 @@ void SetLoggingCategories(const ArgsManager& args) // Now remove the logging categories which were explicitly excluded for (const std::string& cat : args.GetArgs("-debugexclude")) { if (!LogInstance().DisableCategory(cat)) { - InitWarning(strprintf(_("Unsupported logging category %s=%s."), "-debugexclude", cat)); + return util::Error{strprintf(_("Unsupported logging category %s=%s."), "-debugexclude", cat)}; } } + return {}; } bool StartLogging(const ArgsManager& args) diff --git a/src/init/common.h b/src/init/common.h index 44c3a502ee..1c7bcf8671 100644 --- a/src/init/common.h +++ b/src/init/common.h @@ -8,12 +8,14 @@ #ifndef BITCOIN_INIT_COMMON_H #define BITCOIN_INIT_COMMON_H +#include <util/result.h> + class ArgsManager; namespace init { void AddLoggingArgs(ArgsManager& args); void SetLoggingOptions(const ArgsManager& args); -void SetLoggingCategories(const ArgsManager& args); +[[nodiscard]] util::Result<void> SetLoggingCategories(const ArgsManager& args); void SetLoggingLevel(const ArgsManager& args); bool StartLogging(const ArgsManager& args); void LogPackageVersion(); |