fix: debug rpc should return a list of active debug categories, not all of them (#5585)

## Issue being fixed or feature implemented
This restores previous behaviour which was changed/broken here
e554d3a02e (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>
This commit is contained in:
UdjinM6 2023-09-28 15:47:45 +03:00 committed by GitHub
parent 2958aacf5d
commit c034ff0c26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

View File

@ -197,7 +197,7 @@ bool GetLogCategory(BCLog::LogFlags& flag, const std::string& str)
return false;
}
std::vector<LogCategory> BCLog::Logger::LogCategoriesList() const
std::vector<LogCategory> BCLog::Logger::LogCategoriesList(bool enabled_only) const
{
std::vector<LogCategory> ret;
for (const CLogCategoryDesc& category_desc : LogCategories) {
@ -206,7 +206,9 @@ std::vector<LogCategory> 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;

View File

@ -158,11 +158,11 @@ namespace BCLog {
bool WillLogCategory(LogFlags category) const;
/** Returns a vector of the log categories */
std::vector<LogCategory> LogCategoriesList() const;
std::vector<LogCategory> 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;

View File

@ -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)