5#include <bitcoin-build-config.h>
30 argsman.
AddArg(
"-debug=<category>",
"Output debug and trace logging (default: -nodebug, supplying <category> is optional). "
31 "If <category> is not supplied or if <category> is 1 or \"all\", output all debug logging. If <category> is 0 or \"none\", any other categories are ignored. Other valid values for <category> are: " +
LogInstance().LogCategoriesString() +
". This option can be specified multiple times to output multiple categories.",
33 argsman.
AddArg(
"-debugexclude=<category>",
"Exclude debug and trace logging for a category. Can be used in conjunction with -debug=1 to output debug and trace logging for all categories except the specified category. This option can be specified multiple times to exclude multiple categories. This takes priority over \"-debug\"",
ArgsManager::ALLOW_ANY,
OptionsCategory::DEBUG_TEST);
62 for (
const std::string& level_str :
args.
GetArgs(
"-loglevel")) {
63 if (level_str.find_first_of(
':', 3) == std::string::npos) {
71 if (!(toks.size() == 2 &&
LogInstance().SetCategoryLogLevel(toks[0], toks[1]))) {
72 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())};
84 const std::vector<std::string> categories =
args.
GetArgs(
"-debug");
86 if (std::none_of(categories.begin(), categories.end(),
87 [](std::string cat){return cat ==
"0" || cat ==
"none";})) {
88 for (
const auto& cat : categories) {
97 for (
const std::string& cat :
args.
GetArgs(
"-debugexclude")) {
127 LogInfo(
"Config file: <disabled>");
128 }
else if (fs::is_directory(config_file_path)) {
149 version_string +=
" (debug build)";
151 version_string +=
" (release build)";
153 LogPrintf(CLIENT_NAME
" version %s\n", version_string);
fs::path GetDefaultDataDir()
fs::path AbsPathForConfigVal(const ArgsManager &args, const fs::path &path, bool net_specific=true)
Most paths passed as configuration arguments are treated as relative to the datadir if they are not a...
bool IsArgNegated(const std::string &strArg) const
Return true if the argument was originally passed as a negated option, i.e.
@ ALLOW_ANY
disable validation
@ DISALLOW_NEGATION
disallow -nofoo syntax
@ DISALLOW_ELISION
disallow -foo syntax that doesn't assign any value
std::vector< std::string > GetArgs(const std::string &strArg) const
Return a vector of strings of the given argument.
fs::path GetDataDirNet() const
Get data directory path with appended network identifier.
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
fs::path GetConfigFilePath() const
Return config file path (read-only)
void LogArgs() const
Log the config file options and the command line arguments, useful for troubleshooting.
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
void AddArg(const std::string &name, const std::string &help, unsigned int flags, const OptionsCategory &cat)
Add argument.
fs::path GetPathArg(std::string arg, const fs::path &default_value={}) const
Return path argument or default value.
bool m_always_print_category_level
bool m_log_sourcelocations
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
std::string FormatFullVersion()
void InitWarning(const bilingual_str &str)
Show warning message.
bool InitError(const bilingual_str &str)
Show error message.
BCLog::Logger & LogInstance()
const char *const DEFAULT_DEBUGLOGFILE
static const bool DEFAULT_LOGTIMESTAMPS
static const bool DEFAULT_LOGIPS
static const bool DEFAULT_LOGTHREADNAMES
static const bool DEFAULT_LOGSOURCELOCATIONS
static const bool DEFAULT_LOGTIMEMICROS
static constexpr bool DEFAULT_LOGLEVELALWAYS
constexpr auto DEFAULT_LOG_LEVEL
static bool exists(const path &p)
static std::string PathToString(const path &path)
Convert path object to a byte string.
void AddLoggingArgs(ArgsManager &argsman)
util::Result< void > SetLoggingCategories(const ArgsManager &args)
bool StartLogging(const ArgsManager &args)
util::Result< void > SetLoggingLevel(const ArgsManager &args)
void SetLoggingOptions(const ArgsManager &args)
std::vector< std::string > SplitString(std::string_view str, char sep)
int64_t GetTime()
DEPRECATED Use either ClockType::now() or Now<TimePointType>() if a cast is needed.
std::string FormatISO8601DateTime(int64_t nTime)
ISO 8601 formatting is preferred.
bilingual_str _(ConstevalStringLiteral str)
Translation function.
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.