| 77 | } |
| 78 | |
| 79 | util::Result<void> SetLoggingCategories(const ArgsManager& args) |
| 80 | { |
| 81 | const std::vector<std::string> categories = args.GetArgs("-debug"); |
| 82 | |
| 83 | // Special-case: Disregard any debugging categories appearing before -debug=0/none |
| 84 | const auto last_negated = std::find_if(categories.rbegin(), categories.rend(), |
| 85 | [](const std::string& cat) { return cat == "0" || cat == "none"; }); |
| 86 | |
| 87 | const auto categories_to_process = (last_negated == categories.rend()) ? categories : std::ranges::subrange(last_negated.base(), categories.end()); |
| 88 | |
| 89 | for (const auto& cat : categories_to_process) { |
| 90 | if (!LogInstance().EnableCategory(cat)) { |
| 91 | return util::Error{strprintf(_("Unsupported logging category %s=%s."), "-debug", cat)}; |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | // Now remove the logging categories which were explicitly excluded |
| 96 | for (const std::string& cat : args.GetArgs("-debugexclude")) { |
| 97 | if (!LogInstance().DisableCategory(cat)) { |
| 98 | return util::Error{strprintf(_("Unsupported logging category %s=%s."), "-debugexclude", cat)}; |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | LogInfo("Log output may contain privacy-sensitive information. Be cautious when sharing logs."); |
| 103 | |
| 104 | return {}; |
| 105 | } |
| 106 | |
| 107 | bool StartLogging(const ArgsManager& args) |
| 108 | { |
no test coverage detected