From 45f92821621a60891044f57c7a7bc4ab4c7d8a01 Mon Sep 17 00:00:00 2001 From: Jon Atack Date: Wed, 1 Jun 2022 13:44:59 +0200 Subject: Create BCLog::Level::Trace log severity level for verbose log messages for development or debugging only, as bitcoind may run more slowly, that are more granular/frequent than the Debug log level, i.e. for very high-frequency, low-level messages to be logged distinctly from higher-level, less-frequent debug logging that could still be usable in production. An example would be to log higher-level peer events (connection, disconnection, misbehavior, eviction) as Debug, versus Trace for low-level, high-volume p2p messages in the BCLog::NET category. This will enable the user to log only the former without the latter, in order to focus on high-level peer management events. With respect to the name, "trace" is suggested as the most granular level in resources like the following: - https://sematext.com/blog/logging-levels - https://howtodoinjava.com/log4j2/logging-levels Update the test framework and add test coverage. --- src/logging.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/logging.cpp') diff --git a/src/logging.cpp b/src/logging.cpp index 0de74c4913..a609a021d1 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -202,6 +202,8 @@ bool GetLogCategory(BCLog::LogFlags& flag, const std::string& str) std::string BCLog::Logger::LogLevelToStr(BCLog::Level level) const { switch (level) { + case BCLog::Level::Trace: + return "trace"; case BCLog::Level::Debug: return "debug"; case BCLog::Level::Info: @@ -286,7 +288,9 @@ std::string LogCategoryToStr(BCLog::LogFlags category) static std::optional GetLogLevel(const std::string& level_str) { - if (level_str == "debug") { + if (level_str == "trace") { + return BCLog::Level::Trace; + } else if (level_str == "debug") { return BCLog::Level::Debug; } else if (level_str == "info") { return BCLog::Level::Info; @@ -320,9 +324,9 @@ std::vector BCLog::Logger::LogCategoriesList() const } /** Log severity levels that can be selected by the user. */ -static constexpr std::array LogLevelsList() +static constexpr std::array LogLevelsList() { - return {BCLog::Level::Info, BCLog::Level::Debug}; + return {BCLog::Level::Info, BCLog::Level::Debug, BCLog::Level::Trace}; } std::string BCLog::Logger::LogLevelsString() const -- cgit v1.2.3