util: Refactor GetLogCategory.

Changing parameter types from pointers to references and uint32_t to
BCLog::LogFlags simplies calling code.
This commit is contained in:
Jim Posen
2018-04-11 14:06:35 -07:00
parent 3316a9ebb6
commit 1eac317f25
4 changed files with 48 additions and 38 deletions

View File

@@ -349,18 +349,17 @@ UniValue getmemoryinfo(const JSONRPCRequest& request)
void EnableOrDisableLogCategories(UniValue cats, bool enable) {
cats = cats.get_array();
for (unsigned int i = 0; i < cats.size(); ++i) {
uint32_t flag = 0;
std::string cat = cats[i].get_str();
if (!GetLogCategory(&flag, &cat)) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "unknown logging category " + cat);
}
if (flag == BCLog::NONE) {
return;
}
bool success;
if (enable) {
g_logger->EnableCategory(static_cast<BCLog::LogFlags>(flag));
success = g_logger->EnableCategory(cat);
} else {
g_logger->DisableCategory(static_cast<BCLog::LogFlags>(flag));
success = g_logger->DisableCategory(cat);
}
if (!success) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "unknown logging category " + cat);
}
}
}