MCPcopy Create free account
hub / github.com/ElementsProject/elements / logging

Function logging

src/rpc/misc.cpp:639–706  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

637}
638
639static RPCHelpMan logging()
640{
641 return RPCHelpMan{"logging",
642 "Gets and sets the logging configuration.\n"
643 "When called without an argument, returns the list of categories with status that are currently being debug logged or not.\n"
644 "When called with arguments, adds or removes categories from debug logging and return the lists above.\n"
645 "The arguments are evaluated in order \"include\", \"exclude\".\n"
646 "If an item is both included and excluded, it will thus end up being excluded.\n"
647 "The valid logging categories are: " + LogInstance().LogCategoriesString() + "\n"
648 "In addition, the following are available as category names with special meanings:\n"
649 " - \"all\", \"1\" : represent all logging categories.\n"
650 " - \"none\", \"0\" : even if other logging categories are specified, ignore all of them.\n"
651 ,
652 {
653 {"include", RPCArg::Type::ARR, RPCArg::Optional::OMITTED_NAMED_ARG, "The categories to add to debug logging",
654 {
655 {"include_category", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "the valid logging category"},
656 }},
657 {"exclude", RPCArg::Type::ARR, RPCArg::Optional::OMITTED_NAMED_ARG, "The categories to remove from debug logging",
658 {
659 {"exclude_category", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "the valid logging category"},
660 }},
661 },
662 RPCResult{
663 RPCResult::Type::OBJ_DYN, "", "keys are the logging categories, and values indicates its status",
664 {
665 {RPCResult::Type::BOOL, "category", "if being debug logged or not. false:inactive, true:active"},
666 }
667 },
668 RPCExamples{
669 HelpExampleCli("logging", "\"[\\\"all\\\"]\" \"[\\\"http\\\"]\"")
670 + HelpExampleRpc("logging", "[\"all\"], [\"libevent\"]")
671 },
672 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
673{
674 uint32_t original_log_categories = LogInstance().GetCategoryMask();
675 if (request.params[0].isArray()) {
676 EnableOrDisableLogCategories(request.params[0], true);
677 }
678 if (request.params[1].isArray()) {
679 EnableOrDisableLogCategories(request.params[1], false);
680 }
681 uint32_t updated_log_categories = LogInstance().GetCategoryMask();
682 uint32_t changed_log_categories = original_log_categories ^ updated_log_categories;
683
684 // Update libevent logging if BCLog::LIBEVENT has changed.
685 // If the library version doesn't allow it, UpdateHTTPServerLogging() returns false,
686 // in which case we should clear the BCLog::LIBEVENT flag.
687 // Throw an error if the user has explicitly asked to change only the libevent
688 // flag and it failed.
689 if (changed_log_categories & BCLog::LIBEVENT) {
690 if (!UpdateHTTPServerLogging(LogInstance().WillLogCategory(BCLog::LIBEVENT))) {
691 LogInstance().DisableCategory(BCLog::LIBEVENT);
692 if (changed_log_categories == BCLog::LIBEVENT) {
693 throw JSONRPCError(RPC_INVALID_PARAMETER, "libevent logging cannot be updated when using libevent before v2.1.1.");
694 }
695 }
696 }

Callers

nothing calls this directly

Calls 12

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
UpdateHTTPServerLoggingFunction · 0.85
JSONRPCErrorFunction · 0.85
LogCategoriesStringMethod · 0.80
GetCategoryMaskMethod · 0.80
isArrayMethod · 0.80
WillLogCategoryMethod · 0.80
DisableCategoryMethod · 0.80
LogCategoriesListMethod · 0.80
pushKVMethod · 0.45

Tested by

no test coverage detected