| 219 | } |
| 220 | |
| 221 | static RPCMethod logging() |
| 222 | { |
| 223 | return RPCMethod{"logging", |
| 224 | "Gets and sets the logging configuration.\n" |
| 225 | "When called without an argument, returns the list of categories with status that are currently being debug logged or not.\n" |
| 226 | "When called with arguments, adds or removes categories from debug logging and return the lists above.\n" |
| 227 | "The arguments are evaluated in order \"include\", \"exclude\".\n" |
| 228 | "If an item is both included and excluded, it will thus end up being excluded.\n" |
| 229 | "The valid logging categories are: " + LogInstance().LogCategoriesString() + "\n" |
| 230 | "In addition, the following are available as category names with special meanings:\n" |
| 231 | " - \"all\", \"1\" : represent all logging categories.\n" |
| 232 | , |
| 233 | { |
| 234 | {"include", RPCArg::Type::ARR, RPCArg::Optional::OMITTED, "The categories to add to debug logging", |
| 235 | { |
| 236 | {"include_category", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "the valid logging category"}, |
| 237 | }}, |
| 238 | {"exclude", RPCArg::Type::ARR, RPCArg::Optional::OMITTED, "The categories to remove from debug logging", |
| 239 | { |
| 240 | {"exclude_category", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "the valid logging category"}, |
| 241 | }}, |
| 242 | }, |
| 243 | RPCResult{ |
| 244 | RPCResult::Type::OBJ_DYN, "", "keys are the logging categories, and values indicates its status", |
| 245 | { |
| 246 | {RPCResult::Type::BOOL, "category", "if being debug logged or not. false:inactive, true:active"}, |
| 247 | } |
| 248 | }, |
| 249 | RPCExamples{ |
| 250 | HelpExampleCli("logging", "\"[\\\"all\\\"]\" \"[\\\"http\\\"]\"") |
| 251 | + HelpExampleRpc("logging", "[\"all\"], [\"leveldb\"]") |
| 252 | }, |
| 253 | [](const RPCMethod& self, const JSONRPCRequest& request) -> UniValue |
| 254 | { |
| 255 | if (request.params[0].isArray()) { |
| 256 | EnableOrDisableLogCategories(request.params[0], true); |
| 257 | } |
| 258 | if (request.params[1].isArray()) { |
| 259 | EnableOrDisableLogCategories(request.params[1], false); |
| 260 | } |
| 261 | |
| 262 | UniValue result(UniValue::VOBJ); |
| 263 | for (const auto& logCatActive : LogInstance().LogCategoriesList()) { |
| 264 | result.pushKV(logCatActive.category, logCatActive.active); |
| 265 | } |
| 266 | |
| 267 | return result; |
| 268 | }, |
| 269 | }; |
| 270 | } |
| 271 | |
| 272 | static RPCMethod echo(const std::string& name) |
| 273 | { |
nothing calls this directly
no test coverage detected