aboutsummaryrefslogtreecommitdiff
path: root/src/logging.cpp
diff options
context:
space:
mode:
authorklementtan <klementtan@gmail.com>2022-08-18 13:37:25 +0200
committerJon Atack <jon@atack.com>2022-08-20 11:30:51 +0200
commit8fe3457dbb4146952b92fb9509bbe4e97dc1f05b (patch)
tree24617cf6f48b6a1e68b3ee605d5af56caf27be3d /src/logging.cpp
parentc2797cfc602c5cdd899a7c11b37bb5711cebff38 (diff)
Update LogAcceptCategory() and unit tests with log severity levels
Co-authored-by: "Jon Atack <jon@atack.com>"
Diffstat (limited to 'src/logging.cpp')
-rw-r--r--src/logging.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/logging.cpp b/src/logging.cpp
index 3816297820..522b4dc42e 100644
--- a/src/logging.cpp
+++ b/src/logging.cpp
@@ -124,6 +124,19 @@ bool BCLog::Logger::WillLogCategory(BCLog::LogFlags category) const
return (m_categories.load(std::memory_order_relaxed) & category) != 0;
}
+bool BCLog::Logger::WillLogCategoryLevel(BCLog::LogFlags category, BCLog::Level level) const
+{
+ // Log messages at Warning and Error level unconditionally, so that
+ // important troubleshooting information doesn't get lost.
+ if (level >= BCLog::Level::Warning) return true;
+
+ if (!WillLogCategory(category)) return false;
+
+ StdLockGuard scoped_lock(m_cs);
+ const auto it{m_category_log_levels.find(category)};
+ return level >= (it == m_category_log_levels.end() ? LogLevel() : it->second);
+}
+
bool BCLog::Logger::DefaultShrinkDebugFile() const
{
return m_categories == BCLog::NONE;