Skip to content

Commit

Permalink
fix: debug rpc should return a list of active debug categories, not…
Browse files Browse the repository at this point in the history
… all of them
  • Loading branch information
UdjinM6 committed Sep 26, 2023
1 parent 7bff85e commit b5c092b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b5c092b

Please sign in to comment.