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) {
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())};
81 const std::vector<std::string> categories =
args.
GetArgs(
"-debug");
84 const auto last_negated = std::find_if(categories.rbegin(), categories.rend(),
85 [](
const std::string& cat) {
return cat ==
"0" || cat ==
"none"; });
87 const auto categories_to_process = (last_negated == categories.rend()) ? categories : std::ranges::subrange(last_negated.base(), categories.end());
89 for (
const auto& cat : categories_to_process) {
96 for (
const std::string& cat :
args.
GetArgs(
"-debugexclude")) {
126 LogInfo(
"Config file: <disabled>");
127 }
else if (fs::is_directory(config_file_path)) {
148 version_string +=
" (debug build)";
150 version_string +=
" (release build)";
152 LogPrintf(CLIENT_NAME
" version %s\n", version_string);
void EnableCategory(LogFlags flag)
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...
fs::path GetPathArg(std::string arg, const fs::path &default_value={}) const
Return path argument or default value.
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
std::vector< std::string > SplitString(std::string_view str, char sep)
BCLog::Logger & LogInstance()
fs::path GetConfigFilePath() const
Return config file path (read-only)
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
util::Result< void > SetLoggingLevel(const ArgsManager &args)
static const bool DEFAULT_LOGTHREADNAMES
util::Result< void > SetLoggingCategories(const ArgsManager &args)
static const bool DEFAULT_LOGTIMEMICROS
std::string FormatISO8601DateTime(int64_t nTime)
ISO 8601 formatting is preferred.
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
void InitWarning(const bilingual_str &str)
Show warning message.
bool m_log_sourcelocations
consteval auto _(util::TranslatedLiteral str)
constexpr auto DEFAULT_LOG_LEVEL
disallow -foo syntax that doesn't assign any value
bool IsArgNegated(const std::string &strArg) const
Return true if the argument was originally passed as a negated option, i.e.
static constexpr bool DEFAULT_LOGLEVELALWAYS
fs::path GetDataDirNet() const
Get data directory path with appended network identifier.
static std::string PathToString(const path &path)
Convert path object to a byte string.
bool m_always_print_category_level
bool InitError(const bilingual_str &str)
Show error message.
void AddArg(const std::string &name, const std::string &help, unsigned int flags, const OptionsCategory &cat)
Add argument.
bool StartLogging(const ArgsManager &args)
constexpr bool DEFAULT_LOGRATELIMIT
void DisableCategory(LogFlags flag)
void SetCategoryLogLevel(const std::unordered_map< LogFlags, Level > &levels) EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
void SetLogLevel(Level level)
void SetLoggingOptions(const ArgsManager &args)
void AddLoggingArgs(ArgsManager &argsman)
std::string FormatFullVersion()
fs::path GetDefaultDataDir()
static const bool DEFAULT_LOGSOURCELOCATIONS
void LogArgs() const
Log the config file options and the command line arguments, useful for troubleshooting.
static const bool DEFAULT_LOGIPS
std::vector< std::string > GetArgs(const std::string &strArg) const
Return a vector of strings of the given argument.
static bool exists(const path &p)
int64_t GetTime()
DEPRECATED, see GetTime.
const char *const DEFAULT_DEBUGLOGFILE
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
static const bool DEFAULT_LOGTIMESTAMPS