5#if defined(HAVE_CONFIG_H)
6#include <config/bitcoin-config.h>
24 "-debuglogfile=<file>",
25 strprintf(
"Specify location of debug log file. Relative paths will be "
26 "prefixed by a net-specific datadir location. "
27 "(-nodebuglogfile to disable; default: %s)",
30 argsman.
AddArg(
"-debug=<category>",
31 "Output debug and trace logging (default: -nodebug, "
32 "supplying <category> is optional). "
33 "If <category> is not supplied or if <category> = 1, output "
34 "all debug and trace logging. <category> can be: " +
36 ". This option can be specified multiple times to "
37 "output multiple categories.",
40 "-debugexclude=<category>",
42 "Exclude debug and trace logging for a category. Can be used in "
43 "conjunction with -debug=1 to output debug and trace logging for "
44 "all categories except the specified category. This option can be "
45 "specified multiple times to exclude multiple categories."),
49 strprintf(
"Include IP addresses in debug output (default: %u)",
53 "-loglevel=<level>|<category>:<level>",
55 "Set the global or per-category severity level for logging "
56 "categories enabled with the -debug configuration option or the "
57 "logging RPC. Possible values are %s (default=%s); The following "
58 "levels are always logged: error, warning, info. If "
59 "<category>:<level> is supplied, the setting will override the "
60 "global one and may be specified multiple times to set multiple "
61 "category-specific levels. <category> can be: %s.",
70 strprintf(
"Prepend debug output with timestamp (default: %u)",
73#ifdef HAVE_THREAD_LOCAL
77 "Prepend debug output with name of the originating thread (only "
78 "available on platforms supporting thread_local) (default: %u)",
85 "-logsourcelocations",
87 "Prepend debug output with name of the originating source location "
88 "(source file, line number and function name) (default: %u)",
93 strprintf(
"Add microsecond precision to debug timestamps (default: %u)",
99 strprintf(
"Always prepend a category and level (default: %u)",
102 argsman.
AddArg(
"-logratelimit",
103 strprintf(
"Apply rate limiting to unconditional logging to "
104 "mitigate disk-filling attacks (default: %u)",
108 argsman.
AddArg(
"-printtoconsole",
109 "Send trace/debug info to console (default: 1 when no "
110 "-daemon. To disable logging to file, set -nodebuglogfile)",
112 argsman.
AddArg(
"-printpriority",
113 strprintf(
"Log transaction priority and fee per kB when "
114 "mining blocks (default: %d)",
120 "Shrink debug.log file on client startup (default: 1 when no -debug)",
135#ifdef HAVE_THREAD_LOCAL
151 for (
const std::string &level_str : args.
GetArgs(
"-loglevel")) {
152 if (level_str.find_first_of(
':', 3) == std::string::npos) {
156 "-loglevel=%s. Valid values: %s."),
164 if (!(toks.size() == 2 &&
165 LogInstance().SetCategoryLogLevel(toks[0], toks[1]))) {
167 _(
"Unsupported category-specific logging level "
168 "-loglevel=%s. Expected -loglevel=<category>:<loglevel>. "
169 "Valid categories: %s. Valid loglevels: %s."),
181 const std::vector<std::string> categories = args.
GetArgs(
"-debug");
184 categories.begin(), categories.end(),
185 [](std::string cat) { return cat ==
"0" || cat ==
"none"; })) {
186 for (
const auto &cat : categories) {
189 strprintf(
_(
"Unsupported logging category %s=%s."),
197 for (
const std::string &cat : args.
GetArgs(
"-debugexclude")) {
200 "-debugexclude", cat));
235 }
else if (args.
IsArgSet(
"-conf")) {
238 strprintf(
_(
"The specified config file %s does not exist\n"),
242 LogPrintf(
"Config file: %s (not found, skipping)\n",
255 version_string +=
" (debug build)";
257 version_string +=
" (release build)";
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
unimplemented, draft implementation in #16545
@ 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 AddHiddenArgs(const std::vector< std::string > &args)
Add many hidden arguments.
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 DefaultShrinkDebugFile() const
Default for whether ShrinkDebugFile should be run.
bool m_log_sourcelocations
bool StartLogging() EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
Start logging (and flush all buffered messages)
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
std::string FormatFullVersion()
const std::string CLIENT_NAME
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 bool DEFAULT_LOGRATELIMIT
constexpr auto DEFAULT_LOG_LEVEL
static bool exists(const path &p)
static std::string PathToString(const path &path)
Convert path object to byte string.
void AddLoggingArgs(ArgsManager &argsman)
void SetLoggingCategories(const ArgsManager &args)
bool StartLogging(const ArgsManager &args)
void SetLoggingLevel(const ArgsManager &args)
void SetLoggingOptions(const ArgsManager &args)
static const bool DEFAULT_PRINTPRIORITY
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 _(const char *psz)
Translation function.
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
void InitWarning(const bilingual_str &str)
Show warning message.
bool InitError(const bilingual_str &str)
Show error message.