init: raise on invalid debug/debugexclude config options
This commit is contained in:
1 parent
681ecac5c2
commit
4c3c19d943
3 files changed
+11
-5
No files matched your search
+3
-1
@@ -77,6 +77,7 @@
|
|||||||
#include <util/fs.h>
|
#include <util/fs.h>
|
||||||
#include <util/fs_helpers.h>
|
#include <util/fs_helpers.h>
|
||||||
#include <util/moneystr.h>
|
#include <util/moneystr.h>
|
||||||
|
#include <util/result.h>
|
||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
#include <util/string.h>
|
#include <util/string.h>
|
||||||
#include <util/syscall_sandbox.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));
|
InitWarning(strprintf(_("Reducing -maxconnections from %d to %d, because of system limitations."), nUserMaxConnections, nMaxConnections));
|
||||||
|
|
||||||
// ********************************************************* Step 3: parameter-to-internal-flags
|
// ********************************************************* Step 3: parameter-to-internal-flags
|
||||||
init::SetLoggingCategories(args);
|
auto result = init::SetLoggingCategories(args);
|
||||||
|
if (!result) return InitError(util::ErrorString(result));
|
||||||
init::SetLoggingLevel(args);
|
init::SetLoggingLevel(args);
|
||||||
|
|
||||||
nConnectTimeout = args.GetIntArg("-timeout", DEFAULT_CONNECT_TIMEOUT);
|
nConnectTimeout = args.GetIntArg("-timeout", DEFAULT_CONNECT_TIMEOUT);
|
||||||
|
|||||||
+5
-3
@@ -13,6 +13,7 @@
|
|||||||
#include <tinyformat.h>
|
#include <tinyformat.h>
|
||||||
#include <util/fs.h>
|
#include <util/fs.h>
|
||||||
#include <util/fs_helpers.h>
|
#include <util/fs_helpers.h>
|
||||||
|
#include <util/result.h>
|
||||||
#include <util/string.h>
|
#include <util/string.h>
|
||||||
#include <util/time.h>
|
#include <util/time.h>
|
||||||
#include <util/translation.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")) {
|
if (args.IsArgSet("-debug")) {
|
||||||
// Special-case: if -debug=0/-nodebug is set, turn off debugging messages
|
// 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";})) {
|
[](std::string cat){return cat == "0" || cat == "none";})) {
|
||||||
for (const auto& cat : categories) {
|
for (const auto& cat : categories) {
|
||||||
if (!LogInstance().EnableCategory(cat)) {
|
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
|
// Now remove the logging categories which were explicitly excluded
|
||||||
for (const std::string& cat : args.GetArgs("-debugexclude")) {
|
for (const std::string& cat : args.GetArgs("-debugexclude")) {
|
||||||
if (!LogInstance().DisableCategory(cat)) {
|
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)
|
bool StartLogging(const ArgsManager& args)
|
||||||
|
|||||||
+3
-1
@@ -8,12 +8,14 @@
|
|||||||
#ifndef BITCOIN_INIT_COMMON_H
|
#ifndef BITCOIN_INIT_COMMON_H
|
||||||
#define BITCOIN_INIT_COMMON_H
|
#define BITCOIN_INIT_COMMON_H
|
||||||
|
|
||||||
|
#include <util/result.h>
|
||||||
|
|
||||||
class ArgsManager;
|
class ArgsManager;
|
||||||
|
|
||||||
namespace init {
|
namespace init {
|
||||||
void AddLoggingArgs(ArgsManager& args);
|
void AddLoggingArgs(ArgsManager& args);
|
||||||
void SetLoggingOptions(const 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);
|
void SetLoggingLevel(const ArgsManager& args);
|
||||||
bool StartLogging(const ArgsManager& args);
|
bool StartLogging(const ArgsManager& args);
|
||||||
void LogPackageVersion();
|
void LogPackageVersion();
|
||||||
|
|||||||
Reference in new issue
Block a user