aboutsummaryrefslogtreecommitdiff
path: root/src/logging.h
diff options
context:
space:
mode:
authorJim Posen <jimpo@coinbase.com>2018-04-11 13:02:01 -0700
committerJim Posen <jimpo@coinbase.com>2018-04-27 16:10:02 -0700
commit3316a9ebb66171937efddb213daed64fe51c4082 (patch)
treed70ee40dd461cb472fab97e13c4af86dc3180a9e /src/logging.h
parent6a6d764ca5616e5d1f1848b0010613c49bd38e61 (diff)
downloadbitcoin-3316a9ebb66171937efddb213daed64fe51c4082.tar.xz
util: Encapsulate logCategories within BCLog::Logger.
Diffstat (limited to 'src/logging.h')
-rw-r--r--src/logging.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/logging.h b/src/logging.h
index c27a71168b..7a1c25233a 100644
--- a/src/logging.h
+++ b/src/logging.h
@@ -23,8 +23,6 @@ extern const char * const DEFAULT_DEBUGLOGFILE;
extern bool fLogIPs;
-extern std::atomic<uint32_t> logCategories;
-
struct CLogCategoryActive
{
std::string category;
@@ -72,6 +70,9 @@ namespace BCLog {
*/
std::atomic_bool fStartedNewLine{true};
+ /** Log categories bitfield. */
+ std::atomic<uint32_t> logCategories{0};
+
std::string LogTimestampStr(const std::string& str);
public:
@@ -92,6 +93,13 @@ namespace BCLog {
fs::path GetDebugLogPath() const;
bool OpenDebugLog();
void ShrinkDebugFile();
+
+ uint32_t GetCategoryMask() const { return logCategories.load(); }
+ void EnableCategory(LogFlags flag);
+ void DisableCategory(LogFlags flag);
+ bool WillLogCategory(LogFlags category) const;
+
+ bool DefaultShrinkDebugFile() const;
};
} // namespace BCLog
@@ -99,9 +107,9 @@ namespace BCLog {
extern BCLog::Logger* const g_logger;
/** Return true if log accepts specified category */
-static inline bool LogAcceptCategory(uint32_t category)
+static inline bool LogAcceptCategory(BCLog::LogFlags category)
{
- return (logCategories.load(std::memory_order_relaxed) & category) != 0;
+ return g_logger->WillLogCategory(category);
}
/** Returns a string with the log categories. */