aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/misc.cpp
diff options
context:
space:
mode:
authorJim Posen <jimpo@coinbase.com>2018-04-11 14:06:35 -0700
committerJim Posen <jimpo@coinbase.com>2018-04-29 14:37:17 -0700
commit1eac317f25b905e97e311130ab19c3b0d257fc04 (patch)
treecf844c12f7b18d452492200dab948d6ba9d40028 /src/rpc/misc.cpp
parent3316a9ebb66171937efddb213daed64fe51c4082 (diff)
util: Refactor GetLogCategory.
Changing parameter types from pointers to references and uint32_t to BCLog::LogFlags simplies calling code.
Diffstat (limited to 'src/rpc/misc.cpp')
-rw-r--r--src/rpc/misc.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp
index 26bf21356e..0c93108bce 100644
--- a/src/rpc/misc.cpp
+++ b/src/rpc/misc.cpp
@@ -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);
}
}
}