diff options
Diffstat (limited to 'src/init')
-rw-r--r-- | src/init/bitcoin-gui.cpp | 2 | ||||
-rw-r--r-- | src/init/bitcoin-node.cpp | 2 | ||||
-rw-r--r-- | src/init/bitcoin-qt.cpp | 2 | ||||
-rw-r--r-- | src/init/bitcoind.cpp | 2 | ||||
-rw-r--r-- | src/init/common.cpp | 20 | ||||
-rw-r--r-- | src/init/common.h | 6 |
6 files changed, 20 insertions, 14 deletions
diff --git a/src/init/bitcoin-gui.cpp b/src/init/bitcoin-gui.cpp index 100b4ef7ee..ddbdaa6cd0 100644 --- a/src/init/bitcoin-gui.cpp +++ b/src/init/bitcoin-gui.cpp @@ -2,6 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include <common/args.h> #include <interfaces/chain.h> #include <interfaces/echo.h> #include <interfaces/init.h> @@ -10,7 +11,6 @@ #include <interfaces/wallet.h> #include <node/context.h> #include <util/check.h> -#include <util/system.h> #include <memory> diff --git a/src/init/bitcoin-node.cpp b/src/init/bitcoin-node.cpp index 1418e63777..b04596f986 100644 --- a/src/init/bitcoin-node.cpp +++ b/src/init/bitcoin-node.cpp @@ -2,6 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include <common/args.h> #include <interfaces/chain.h> #include <interfaces/echo.h> #include <interfaces/init.h> @@ -10,7 +11,6 @@ #include <interfaces/wallet.h> #include <node/context.h> #include <util/check.h> -#include <util/system.h> #include <memory> diff --git a/src/init/bitcoin-qt.cpp b/src/init/bitcoin-qt.cpp index e27be0e598..dd5826d982 100644 --- a/src/init/bitcoin-qt.cpp +++ b/src/init/bitcoin-qt.cpp @@ -2,6 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include <common/args.h> #include <interfaces/chain.h> #include <interfaces/echo.h> #include <interfaces/init.h> @@ -9,7 +10,6 @@ #include <interfaces/wallet.h> #include <node/context.h> #include <util/check.h> -#include <util/system.h> #include <memory> diff --git a/src/init/bitcoind.cpp b/src/init/bitcoind.cpp index 7ad1f64e64..210608370c 100644 --- a/src/init/bitcoind.cpp +++ b/src/init/bitcoind.cpp @@ -2,6 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include <common/args.h> #include <interfaces/chain.h> #include <interfaces/echo.h> #include <interfaces/init.h> @@ -9,7 +10,6 @@ #include <interfaces/wallet.h> #include <node/context.h> #include <util/check.h> -#include <util/system.h> #include <memory> diff --git a/src/init/common.cpp b/src/init/common.cpp index a7829c5d99..f3f7c696c5 100644 --- a/src/init/common.cpp +++ b/src/init/common.cpp @@ -7,12 +7,14 @@ #endif #include <clientversion.h> -#include <fs.h> +#include <common/args.h> #include <logging.h> #include <node/interface_ui.h> #include <tinyformat.h> +#include <util/fs.h> +#include <util/fs_helpers.h> +#include <util/result.h> #include <util/string.h> -#include <util/system.h> #include <util/time.h> #include <util/translation.h> @@ -57,27 +59,28 @@ 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 %s=%s. Valid values: %s."), "-loglevel", 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 %1$s=%2$s. Expected %1$s=<category>:<loglevel>. Valid categories: %3$s. Valid loglevels: %4$s."), "-loglevel", level_str, LogInstance().LogCategoriesString(), LogInstance().LogLevelsString())}; } } } } + return {}; } -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 @@ -87,7 +90,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)}; } } } @@ -96,9 +99,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..b61a77c6d4 100644 --- a/src/init/common.h +++ b/src/init/common.h @@ -8,13 +8,15 @@ #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); -void SetLoggingLevel(const ArgsManager& args); +[[nodiscard]] util::Result<void> SetLoggingCategories(const ArgsManager& args); +[[nodiscard]] util::Result<void> SetLoggingLevel(const ArgsManager& args); bool StartLogging(const ArgsManager& args); void LogPackageVersion(); } // namespace init |