Skip to content

Commit c034ff0

Browse files
fix: debug rpc should return a list of active debug categories, not all of them (dashpay#5585)
## Issue being fixed or feature implemented This restores previous behaviour which was changed/broken here dashpay@e554d3a#diff-0ba691cbdd97c095286e9373ed8d5be87d559234440487956326965e16cbb421R75 ## What was done? Fix `debug` rpc results ## How Has This Been Tested? Run rpc, check results ## Breaking Changes n/a ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ --------- Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>
1 parent 2958aac commit c034ff0

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/logging.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ bool GetLogCategory(BCLog::LogFlags& flag, const std::string& str)
197197
return false;
198198
}
199199

200-
std::vector<LogCategory> BCLog::Logger::LogCategoriesList() const
200+
std::vector<LogCategory> BCLog::Logger::LogCategoriesList(bool enabled_only) const
201201
{
202202
std::vector<LogCategory> ret;
203203
for (const CLogCategoryDesc& category_desc : LogCategories) {
@@ -206,7 +206,9 @@ std::vector<LogCategory> BCLog::Logger::LogCategoriesList() const
206206
LogCategory catActive;
207207
catActive.category = category_desc.category;
208208
catActive.active = WillLogCategory(category_desc.flag);
209-
ret.push_back(catActive);
209+
if (!enabled_only || catActive.active) {
210+
ret.push_back(catActive);
211+
}
210212
}
211213
}
212214
return ret;

src/logging.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,11 @@ namespace BCLog {
158158

159159
bool WillLogCategory(LogFlags category) const;
160160
/** Returns a vector of the log categories */
161-
std::vector<LogCategory> LogCategoriesList() const;
161+
std::vector<LogCategory> LogCategoriesList(bool enabled_only = false) const;
162162
/** Returns a string with the log categories */
163-
std::string LogCategoriesString() const
163+
std::string LogCategoriesString(bool enabled_only = false) const
164164
{
165-
return Join(LogCategoriesList(), ", ", [&](const LogCategory& i) { return i.category; });
165+
return Join(LogCategoriesList(enabled_only), ", ", [&](const LogCategory& i) { return i.category; });
166166
};
167167

168168
bool DefaultShrinkDebugFile() const;

src/rpc/misc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static UniValue debug(const JSONRPCRequest& request)
7272
}
7373
}
7474

75-
return "Debug mode: " + LogInstance().LogCategoriesString();
75+
return "Debug mode: " + LogInstance().LogCategoriesString(/*enabled_only=*/true);
7676
}
7777

7878
static UniValue mnsync(const JSONRPCRequest& request)

0 commit comments

Comments
 (0)