| 58 | } |
| 59 | |
| 60 | util::Result<void> SetLoggingLevel(const ArgsManager& args) |
| 61 | { |
| 62 | for (const std::string& level_str : args.GetArgs("-loglevel")) { |
| 63 | if (level_str.find_first_of(':', 3) == std::string::npos) { |
| 64 | // user passed a global log level, i.e. -loglevel=<level> |
| 65 | if (!LogInstance().SetLogLevel(level_str)) { |
| 66 | return util::Error{strprintf(_("Unsupported global logging level %s=%s. Valid values: %s."), "-loglevel", level_str, LogInstance().LogLevelsString())}; |
| 67 | } |
| 68 | } else { |
| 69 | // user passed a category-specific log level, i.e. -loglevel=<category>:<level> |
| 70 | const auto& toks = SplitString(level_str, ':'); |
| 71 | if (!(toks.size() == 2 && LogInstance().SetCategoryLogLevel(toks[0], toks[1]))) { |
| 72 | return util::Error{strprintf(_("Unsupported category-specific logging level %1$s=%2$s. Expected %1$s=<category>:<loglevel>. Valid categories: %3$s. Valid loglevels: %4$s."), "-loglevel", level_str, LogInstance().LogCategoriesString(), LogInstance().LogLevelsString())}; |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | return {}; |
| 77 | } |
| 78 | |
| 79 | util::Result<void> SetLoggingCategories(const ArgsManager& args) |
| 80 | { |