diff options
author | Jon Atack <jon@atack.com> | 2023-05-12 00:58:35 +0200 |
---|---|---|
committer | Jon Atack <jon@atack.com> | 2023-06-14 08:27:46 -0600 |
commit | a9c295888b82c86ef4629aa2d9061ea152b48f20 (patch) | |
tree | 95deaed578ab6dac62097b6d814854689198798f /src/init | |
parent | b0c3995393c592fa96306e077ed64e65d5400882 (diff) |
init: raise on invalid loglevel config option
Diffstat (limited to 'src/init')
-rw-r--r-- | src/init/common.cpp | 7 | ||||
-rw-r--r-- | src/init/common.h | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/src/init/common.cpp b/src/init/common.cpp index 2c36d30fdf..b9c19725b1 100644 --- a/src/init/common.cpp +++ b/src/init/common.cpp @@ -59,24 +59,25 @@ void SetLoggingOptions(const ArgsManager& args) fLogIPs = args.GetBoolArg("-logips", DEFAULT_LOGIPS); } -void SetLoggingLevel(const ArgsManager& args) +util::Result<void> SetLoggingLevel(const ArgsManager& args) { if (args.IsArgSet("-loglevel")) { for (const std::string& level_str : args.GetArgs("-loglevel")) { if (level_str.find_first_of(':', 3) == std::string::npos) { // user passed a global log level, i.e. -loglevel=<level> if (!LogInstance().SetLogLevel(level_str)) { - InitWarning(strprintf(_("Unsupported global logging level -loglevel=%s. Valid values: %s."), level_str, LogInstance().LogLevelsString())); + return util::Error{strprintf(_("Unsupported global logging level -loglevel=%s. Valid values: %s."), level_str, LogInstance().LogLevelsString())}; } } else { // user passed a category-specific log level, i.e. -loglevel=<category>:<level> const auto& toks = SplitString(level_str, ':'); if (!(toks.size() == 2 && LogInstance().SetCategoryLogLevel(toks[0], toks[1]))) { - InitWarning(strprintf(_("Unsupported category-specific logging level -loglevel=%s. Expected -loglevel=<category>:<loglevel>. Valid categories: %s. Valid loglevels: %s."), level_str, LogInstance().LogCategoriesString(), LogInstance().LogLevelsString())); + return util::Error{strprintf(_("Unsupported category-specific logging level -loglevel=%s. Expected -loglevel=<category>:<loglevel>. Valid categories: %s. Valid loglevels: %s."), level_str, LogInstance().LogCategoriesString(), LogInstance().LogLevelsString())}; } } } } + return {}; } util::Result<void> SetLoggingCategories(const ArgsManager& args) diff --git a/src/init/common.h b/src/init/common.h index 1c7bcf8671..b61a77c6d4 100644 --- a/src/init/common.h +++ b/src/init/common.h @@ -16,7 +16,7 @@ namespace init { void AddLoggingArgs(ArgsManager& args); void SetLoggingOptions(const ArgsManager& args); [[nodiscard]] util::Result<void> SetLoggingCategories(const ArgsManager& args); -void SetLoggingLevel(const ArgsManager& args); +[[nodiscard]] util::Result<void> SetLoggingLevel(const ArgsManager& args); bool StartLogging(const ArgsManager& args); void LogPackageVersion(); } // namespace init |