diff options
author | MarcoFalke <falke.marco@gmail.com> | 2020-04-26 19:57:33 -0400 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2020-04-26 19:57:41 -0400 |
commit | ae32e5ce3d268881cbf631de1903b2a414bb64e1 (patch) | |
tree | 8244f733f93ae306b904b1015165e7012949dccb /src/logging.h | |
parent | 9ddfce671263e41aa27d56747c23c3240efdfab8 (diff) | |
parent | faec0638872798b58b9882ee079014555bc8393e (diff) | |
download | bitcoin-ae32e5ce3d268881cbf631de1903b2a414bb64e1.tar.xz |
Merge #18669: log: Use Join() helper when listing log categories
faec0638872798b58b9882ee079014555bc8393e log: Use Join() helper when listing log categories (MarcoFalke)
Pull request description:
This removes the global `ListLogCategories` and replaces it with a one-line member function `LogCategoriesString`, which just calls `Join`.
Should be a straightforward refactor to get rid of a few LOC.
ACKs for top commit:
laanwj:
ACK faec0638872798b58b9882ee079014555bc8393e
promag:
ACK faec0638872798b58b9882ee079014555bc8393e, I also think it's fine as it is (re https://github.com/bitcoin/bitcoin/pull/18669#discussion_r412944724).
Tree-SHA512: 2f51f9ce1246eda5630015f3a869e36953c7eb34f311baad576b92d7829e4e88051c6189436271cd0a13732a49698506345b446b98fd28e58edfb5b62169f1c9
Diffstat (limited to 'src/logging.h')
-rw-r--r-- | src/logging.h | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/logging.h b/src/logging.h index b2fde1b9ea..ab07010316 100644 --- a/src/logging.h +++ b/src/logging.h @@ -8,6 +8,7 @@ #include <fs.h> #include <tinyformat.h> +#include <util/string.h> #include <atomic> #include <cstdint> @@ -24,8 +25,7 @@ extern const char * const DEFAULT_DEBUGLOGFILE; extern bool fLogIPs; -struct CLogCategoryActive -{ +struct LogCategory { std::string category; bool active; }; @@ -132,6 +132,13 @@ namespace BCLog { bool DisableCategory(const std::string& str); bool WillLogCategory(LogFlags category) const; + /** Returns a vector of the log categories */ + std::vector<LogCategory> LogCategoriesList(); + /** Returns a string with the log categories */ + std::string LogCategoriesString() + { + return Join(LogCategoriesList(), ", ", [&](const LogCategory& i) { return i.category; }); + }; bool DefaultShrinkDebugFile() const; }; @@ -146,12 +153,6 @@ static inline bool LogAcceptCategory(BCLog::LogFlags category) return LogInstance().WillLogCategory(category); } -/** Returns a string with the log categories. */ -std::string ListLogCategories(); - -/** Returns a vector of the active log categories. */ -std::vector<CLogCategoryActive> ListActiveLogCategories(); - /** Return true if str parses as a log category and set the flag */ bool GetLogCategory(BCLog::LogFlags& flag, const std::string& str); |