diff options
| author | Jim Posen <[email protected]> | 2018-04-11 13:02:01 -0700 |
|---|---|---|
| committer | Jim Posen <[email protected]> | 2018-04-27 16:10:02 -0700 |
| commit | 3316a9ebb66171937efddb213daed64fe51c4082 (patch) | |
| tree | d70ee40dd461cb472fab97e13c4af86dc3180a9e /src/logging.cpp | |
| parent | util: Move debug file management functions into Logger. (diff) | |
| download | discoin-3316a9ebb66171937efddb213daed64fe51c4082.tar.xz discoin-3316a9ebb66171937efddb213daed64fe51c4082.zip | |
util: Encapsulate logCategories within BCLog::Logger.
Diffstat (limited to 'src/logging.cpp')
| -rw-r--r-- | src/logging.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/logging.cpp b/src/logging.cpp index ed225a6a6..7604c0fd9 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<uint32_t> 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; |