diff --git a/src/logging.cpp b/src/logging.cpp index 7b4a5956c7..e64d76c988 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -197,7 +197,7 @@ bool GetLogCategory(BCLog::LogFlags& flag, const std::string& str) return false; } -std::vector BCLog::Logger::LogCategoriesList() const +std::vector BCLog::Logger::LogCategoriesList(bool enabled_only) const { std::vector ret; for (const CLogCategoryDesc& category_desc : LogCategories) { @@ -206,7 +206,9 @@ std::vector BCLog::Logger::LogCategoriesList() const LogCategory catActive; catActive.category = category_desc.category; catActive.active = WillLogCategory(category_desc.flag); - ret.push_back(catActive); + if (!enabled_only || catActive.active) { + ret.push_back(catActive); + } } } return ret; diff --git a/src/logging.h b/src/logging.h index 7810e318ce..af3423edf8 100644 --- a/src/logging.h +++ b/src/logging.h @@ -158,11 +158,11 @@ namespace BCLog { bool WillLogCategory(LogFlags category) const; /** Returns a vector of the log categories */ - std::vector LogCategoriesList() const; + std::vector LogCategoriesList(bool enabled_only = false) const; /** Returns a string with the log categories */ - std::string LogCategoriesString() const + std::string LogCategoriesString(bool enabled_only = false) const { - return Join(LogCategoriesList(), ", ", [&](const LogCategory& i) { return i.category; }); + return Join(LogCategoriesList(enabled_only), ", ", [&](const LogCategory& i) { return i.category; }); }; bool DefaultShrinkDebugFile() const; diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index edf09cfb13..c4cf607f61 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -72,7 +72,7 @@ static UniValue debug(const JSONRPCRequest& request) } } - return "Debug mode: " + LogInstance().LogCategoriesString(); + return "Debug mode: " + LogInstance().LogCategoriesString(/*enabled_only=*/true); } static UniValue mnsync(const JSONRPCRequest& request)