mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-27 22:34:18 +02:00
logging: Move GetLogCategory into Logger class
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user