nit: would it make sense to just move this to BCLog, out of ::Logger?
<details>
<summary>git diff on e60fc7d5d3</summary>
diff --git a/src/init/common.cpp b/src/init/common.cpp
index 6560258ef5..0832845921 100644
--- a/src/init/common.cpp
+++ b/src/init/common.cpp
@@ -31,7 +31,7 @@ void AddLoggingArgs(ArgsManager& argsman)
ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
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.", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
argsman.AddArg("-logips", strprintf("Include IP addresses in debug output (default: %u)", DEFAULT_LOGIPS), ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
- argsman.AddArg("-loglevel=<level>|<category>:<level>", strprintf("Set the global or per-category severity level for logging categories enabled with the -debug configuration option or the logging RPC: %s (default=%s); warning and error levels are always logged. If <category>:<level> is supplied, the setting will override the global one and may be specified multiple times to set multiple category-specific levels. <category> can be: %s.", LogInstance().LogLevelsString(), LogInstance().LogLevelToStr(BCLog::DEFAULT_LOG_LEVEL), LogInstance().LogCategoriesString()), ArgsManager::DISALLOW_NEGATION | ArgsManager::DISALLOW_ELISION | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
+ argsman.AddArg("-loglevel=<level>|<category>:<level>", strprintf("Set the global or per-category severity level for logging categories enabled with the -debug configuration option or the logging RPC: %s (default=%s); warning and error levels are always logged. If <category>:<level> is supplied, the setting will override the global one and may be specified multiple times to set multiple category-specific levels. <category> can be: %s.", LogInstance().LogLevelsString(), BCLog::LogLevelToStr(BCLog::DEFAULT_LOG_LEVEL), LogInstance().LogCategoriesString()), ArgsManager::DISALLOW_NEGATION | ArgsManager::DISALLOW_ELISION | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
argsman.AddArg("-logtimestamps", strprintf("Prepend debug output with timestamp (default: %u)", DEFAULT_LOGTIMESTAMPS), ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
#ifdef HAVE_THREAD_LOCAL
argsman.AddArg("-logthreadnames", strprintf("Prepend debug output with name of the originating thread (only available on platforms supporting thread_local) (default: %u)", DEFAULT_LOGTHREADNAMES), ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
diff --git a/src/logging.cpp b/src/logging.cpp
index 42f100ded6..b1f0efbbd8 100644
--- a/src/logging.cpp
+++ b/src/logging.cpp
@@ -202,7 +202,7 @@ bool GetLogCategory(BCLog::LogFlags& flag, const std::string& str)
return false;
}
-std::string BCLog::Logger::LogLevelToStr(BCLog::Level level)
+std::string BCLog::LogLevelToStr(BCLog::Level level)
{
switch (level) {
case BCLog::Level::Trace:
@@ -407,7 +407,7 @@ std::string BCLog::Logger::GetLogPrefix(BCLog::LogFlags category, BCLog::Level l
// Only add separator if we have a category
if (has_category) s += ":";
- s += Logger::LogLevelToStr(level);
+ s += LogLevelToStr(level);
}
s += "] ";
diff --git a/src/logging.h b/src/logging.h
index 525e0aec6d..a2228ac7ba 100644
--- a/src/logging.h
+++ b/src/logging.h
@@ -81,6 +81,9 @@ namespace BCLog {
};
constexpr auto DEFAULT_LOG_LEVEL{Level::Debug};
+ //! Returns the string representation of a log level.
+ std::string LogLevelToStr(BCLog::Level level);
+
class Logger
{
private:
@@ -196,9 +199,6 @@ namespace BCLog {
//! Returns a string with all user-selectable log levels.
std::string LogLevelsString() const;
- //! Returns the string representation of a log level.
- static std::string LogLevelToStr(BCLog::Level level);
-
bool DefaultShrinkDebugFile() const;
};
</details>