From 3316a9ebb66171937efddb213daed64fe51c4082 Mon Sep 17 00:00:00 2001 From: Jim Posen Date: Wed, 11 Apr 2018 13:02:01 -0700 Subject: util: Encapsulate logCategories within BCLog::Logger. --- src/logging.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src/logging.cpp') diff --git a/src/logging.cpp b/src/logging.cpp index ed225a6a67..7604c0fd94 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -26,9 +26,6 @@ BCLog::Logger* const g_logger = new BCLog::Logger(); bool fLogIPs = DEFAULT_LOGIPS; -/** Log categories bitfield. */ -std::atomic logCategories(0); - static int FileWriteStr(const std::string &str, FILE *fp) { return fwrite(str.data(), 1, str.size(), fp); @@ -62,6 +59,26 @@ bool BCLog::Logger::OpenDebugLog() return true; } +void BCLog::Logger::EnableCategory(BCLog::LogFlags flag) +{ + logCategories |= flag; +} + +void BCLog::Logger::DisableCategory(BCLog::LogFlags flag) +{ + logCategories &= ~flag; +} + +bool BCLog::Logger::WillLogCategory(BCLog::LogFlags category) const +{ + return (logCategories.load(std::memory_order_relaxed) & category) != 0; +} + +bool BCLog::Logger::DefaultShrinkDebugFile() const +{ + return logCategories == BCLog::NONE; +} + struct CLogCategoryDesc { uint32_t flag; -- cgit v1.2.3