mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 03:47:29 -03:00
init: raise on invalid debug/debugexclude config options
This commit is contained in:
parent
681ecac5c2
commit
4c3c19d943
3 changed files with 11 additions and 5 deletions
|
@ -77,6 +77,7 @@
|
|||
#include <util/fs.h>
|
||||
#include <util/fs_helpers.h>
|
||||
#include <util/moneystr.h>
|
||||
#include <util/result.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/string.h>
|
||||
#include <util/syscall_sandbox.h>
|
||||
|
@ -949,7 +950,8 @@ bool AppInitParameterInteraction(const ArgsManager& args, bool use_syscall_sandb
|
|||
InitWarning(strprintf(_("Reducing -maxconnections from %d to %d, because of system limitations."), nUserMaxConnections, nMaxConnections));
|
||||
|
||||
// ********************************************************* Step 3: parameter-to-internal-flags
|
||||
init::SetLoggingCategories(args);
|
||||
auto result = init::SetLoggingCategories(args);
|
||||
if (!result) return InitError(util::ErrorString(result));
|
||||
init::SetLoggingLevel(args);
|
||||
|
||||
nConnectTimeout = args.GetIntArg("-timeout", DEFAULT_CONNECT_TIMEOUT);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue