aboutsummaryrefslogtreecommitdiff
path: root/src/init
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2023-09-12 14:27:26 +1000
committerAnthony Towns <aj@erisian.com.au>2023-12-15 11:03:25 +1000
commitfbd7642c8e5b70327e019382320f5ef0a651ecc5 (patch)
tree7d8c0aa37cbe659a7a237cc4d2aa18663688ad05 /src/init
parent782bb6a05663ad7a53908e910d0f42b49b881e09 (diff)
downloadbitcoin-fbd7642c8e5b70327e019382320f5ef0a651ecc5.tar.xz
logging: add -loglevelalways=1 option
This option tells the logging system to always include a "[cat:level]" prefix, so [net] becomes [net:debug], LogInfo/LogPrint statements will have an [all:info] prefix, and LogWarning and LogError logs will become [all:warning] and [all:error]. This may be easier for automated parsing of logs, particularly if additional prefixes such as thread or source location are enabled.
Diffstat (limited to 'src/init')
-rw-r--r--src/init/common.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/init/common.cpp b/src/init/common.cpp
index f3f7c696c5..6560258ef5 100644
--- a/src/init/common.cpp
+++ b/src/init/common.cpp
@@ -40,6 +40,7 @@ void AddLoggingArgs(ArgsManager& argsman)
#endif
argsman.AddArg("-logsourcelocations", strprintf("Prepend debug output with name of the originating source location (source file, line number and function name) (default: %u)", DEFAULT_LOGSOURCELOCATIONS), ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
argsman.AddArg("-logtimemicros", strprintf("Add microsecond precision to debug timestamps (default: %u)", DEFAULT_LOGTIMEMICROS), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
+ argsman.AddArg("-loglevelalways", strprintf("Always prepend a category and level (default: %u)", DEFAULT_LOGLEVELALWAYS), ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
argsman.AddArg("-printtoconsole", "Send trace/debug info to console (default: 1 when no -daemon. To disable logging to file, set -nodebuglogfile)", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
argsman.AddArg("-shrinkdebugfile", "Shrink debug.log file on client startup (default: 1 when no -debug)", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
}
@@ -55,6 +56,7 @@ void SetLoggingOptions(const ArgsManager& args)
LogInstance().m_log_threadnames = args.GetBoolArg("-logthreadnames", DEFAULT_LOGTHREADNAMES);
#endif
LogInstance().m_log_sourcelocations = args.GetBoolArg("-logsourcelocations", DEFAULT_LOGSOURCELOCATIONS);
+ LogInstance().m_always_print_category_level = args.GetBoolArg("-loglevelalways", DEFAULT_LOGLEVELALWAYS);
fLogIPs = args.GetBoolArg("-logips", DEFAULT_LOGIPS);
}