From abea304dd6d726acaeab3aab99df5c24467adc2f Mon Sep 17 00:00:00 2001 From: Anthony Towns Date: Wed, 11 Feb 2026 08:15:09 +1000 Subject: [PATCH] logging: Move GetLogCategory into Logger class --- src/logging.cpp | 2 +- src/logging.h | 6 +++--- src/test/logging_tests.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/logging.cpp b/src/logging.cpp index 0edc970df67..fc6dd1b8268 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -224,7 +224,7 @@ static const std::unordered_map LOG_CATEGORIES_BY_ }(LOG_CATEGORIES_BY_STR) }; -std::optional GetLogCategory(std::string_view str) +std::optional BCLog::Logger::GetLogCategory(std::string_view str) { if (str.empty() || str == "1" || str == "all") { return BCLog::ALL; diff --git a/src/logging.h b/src/logging.h index 9ff1c7ea4d2..a727dc249d1 100644 --- a/src/logging.h +++ b/src/logging.h @@ -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 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 GetLogCategory(std::string_view str); - #endif // BITCOIN_LOGGING_H diff --git a/src/test/logging_tests.cpp b/src/test/logging_tests.cpp index 550ef85cc4a..5595fe16de4 100644 --- a/src/test/logging_tests.cpp +++ b/src/test/logging_tests.cpp @@ -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); }