aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorklementtan <klementtan@gmail.com>2022-08-18 13:56:36 +0200
committerJon Atack <jon@atack.com>2022-08-20 11:31:28 +0200
commit9c7507bf76e79da99766a69df939520ea0a125d1 (patch)
tree404aea6dee76ebedbd132aff2d42490e71264ba0
parent8fe3457dbb4146952b92fb9509bbe4e97dc1f05b (diff)
Create BCLog::Logger::LogLevelsString() helper function
Co-authored-by: "Jon Atack <jon@atack.com>"
-rw-r--r--src/logging.cpp12
-rw-r--r--src/logging.h3
2 files changed, 15 insertions, 0 deletions
diff --git a/src/logging.cpp b/src/logging.cpp
index 522b4dc42e..214f6af9a7 100644
--- a/src/logging.cpp
+++ b/src/logging.cpp
@@ -319,6 +319,18 @@ std::vector<LogCategory> BCLog::Logger::LogCategoriesList() const
return ret;
}
+/** Log severity levels that can be selected by the user. */
+static constexpr std::array<BCLog::Level, 2> LogLevelsList()
+{
+ return {BCLog::Level::Info, BCLog::Level::Debug};
+}
+
+std::string BCLog::Logger::LogLevelsString() const
+{
+ const auto& levels = LogLevelsList();
+ return Join(std::vector<BCLog::Level>{levels.begin(), levels.end()}, ", ", [this](BCLog::Level level) { return LogLevelToStr(level); });
+}
+
std::string BCLog::Logger::LogTimestampStr(const std::string& str)
{
std::string strStamped;
diff --git a/src/logging.h b/src/logging.h
index 76bed39e91..680eb47f4b 100644
--- a/src/logging.h
+++ b/src/logging.h
@@ -186,6 +186,9 @@ namespace BCLog {
return Join(LogCategoriesList(), ", ", [&](const LogCategory& i) { return i.category; });
};
+ //! Returns a string with all user-selectable log levels.
+ std::string LogLevelsString() const;
+
bool DefaultShrinkDebugFile() const;
};