logging: Move GetLogCategory into Logger class

This commit is contained in:
Anthony Towns
2026-02-11 08:15:09 +10:00
parent 58113e5833
commit abea304dd6
3 changed files with 5 additions and 5 deletions

View File

@@ -224,7 +224,7 @@ static const std::unordered_map<BCLog::LogFlags, std::string> LOG_CATEGORIES_BY_
}(LOG_CATEGORIES_BY_STR)
};
std::optional<BCLog::LogFlags> GetLogCategory(std::string_view str)
std::optional<BCLog::LogFlags> BCLog::Logger::GetLogCategory(std::string_view str)
{
if (str.empty() || str == "1" || str == "all") {
return BCLog::ALL;

View File

@@ -275,6 +275,9 @@ namespace BCLog {
static std::string LogLevelToStr(BCLog::Level level);
bool DefaultShrinkDebugFile() const;
//! Return log flag if str parses as a log category.
static std::optional<BCLog::LogFlags> GetLogCategory(std::string_view str);
};
} // namespace BCLog
@@ -286,7 +289,4 @@ static inline bool LogAcceptCategory(BCLog::LogFlags category, BCLog::Level leve
return LogInstance().WillLogCategoryLevel(category, level);
}
/// Return log flag if str parses as a log category.
std::optional<BCLog::LogFlags> GetLogCategory(std::string_view str);
#endif // BITCOIN_LOGGING_H

View File

@@ -166,7 +166,7 @@ BOOST_FIXTURE_TEST_CASE(logging_LogPrintMacros_CategoryName, LogSetup)
const auto category_names = SplitString(concatenated_category_names, ',');
for (const auto& category_name : category_names) {
const auto trimmed_category_name = TrimString(category_name);
const auto category{*Assert(GetLogCategory(trimmed_category_name))};
const auto category{*Assert(BCLog::Logger::GetLogCategory(trimmed_category_name))};
expected_category_names.emplace_back(category, trimmed_category_name);
}