From b5c092b9a7780cfb8d1afb27cff5df7db2b8ec42 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Tue, 26 Sep 2023 20:10:28 +0300 Subject: [PATCH] fix: `debug` rpc should return a list of active debug categories, not all of them --- src/logging.cpp | 6 ++++-- src/logging.h | 6 +++--- src/rpc/misc.cpp | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/logging.cpp b/src/logging.cpp index 7b4a5956c75c8..e64d76c9881f7 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 7810e318cebe0..af3423edf84bf 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 56eb970fab868..c1e53d3f176a3 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -71,7 +71,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)