mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
util: Encapsulate logCategories within BCLog::Logger.
This commit is contained in:
@@ -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. */
|
||||
|
||||
Reference in New Issue
Block a user