diff options
author | Jim Posen <jimpo@coinbase.com> | 2018-04-11 14:06:35 -0700 |
---|---|---|
committer | Jim Posen <jimpo@coinbase.com> | 2018-04-29 14:37:17 -0700 |
commit | 1eac317f25b905e97e311130ab19c3b0d257fc04 (patch) | |
tree | cf844c12f7b18d452492200dab948d6ba9d40028 /src/rpc/misc.cpp | |
parent | 3316a9ebb66171937efddb213daed64fe51c4082 (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.cpp | 17 |
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); } } } |