Changeset View
Changeset View
Standalone View
Standalone View
src/logging.h
Show First 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | public: | ||||
bool WillLogCategory(LogFlags category) const; | bool WillLogCategory(LogFlags category) const; | ||||
/** Default for whether ShrinkDebugFile should be run */ | /** Default for whether ShrinkDebugFile should be run */ | ||||
bool DefaultShrinkDebugFile() const; | bool DefaultShrinkDebugFile() const; | ||||
}; | }; | ||||
} // namespace BCLog | } // namespace BCLog | ||||
BCLog::Logger &GetLogger(); | BCLog::Logger &LogInstance(); | ||||
/** Return true if log accepts specified category */ | /** Return true if log accepts specified category */ | ||||
static inline bool LogAcceptCategory(BCLog::LogFlags category) { | static inline bool LogAcceptCategory(BCLog::LogFlags category) { | ||||
return GetLogger().WillLogCategory(category); | return LogInstance().WillLogCategory(category); | ||||
} | } | ||||
/** Returns a string with the log categories. */ | /** Returns a string with the log categories. */ | ||||
std::string ListLogCategories(); | std::string ListLogCategories(); | ||||
/** Returns a vector of the active log categories. */ | /** Returns a vector of the active log categories. */ | ||||
std::vector<CLogCategoryActive> ListActiveLogCategories(); | std::vector<CLogCategoryActive> ListActiveLogCategories(); | ||||
Show All 19 Lines | |||||
#define LogPrint(category, ...) \ | #define LogPrint(category, ...) \ | ||||
do { \ | do { \ | ||||
MarkUsed(__VA_ARGS__); \ | MarkUsed(__VA_ARGS__); \ | ||||
} while (0) | } while (0) | ||||
#else | #else | ||||
#define LogPrint(category, ...) \ | #define LogPrint(category, ...) \ | ||||
do { \ | do { \ | ||||
if (LogAcceptCategory((category))) { \ | if (LogAcceptCategory((category))) { \ | ||||
GetLogger().LogPrintStr(tfm::format(__VA_ARGS__)); \ | LogInstance().LogPrintStr(tfm::format(__VA_ARGS__)); \ | ||||
} \ | } \ | ||||
} while (0) | } while (0) | ||||
#define LogPrintf(...) \ | #define LogPrintf(...) \ | ||||
do { \ | do { \ | ||||
GetLogger().LogPrintStr(tfm::format(__VA_ARGS__)); \ | LogInstance().LogPrintStr(tfm::format(__VA_ARGS__)); \ | ||||
} while (0) | } while (0) | ||||
#endif | #endif | ||||
/** | /** | ||||
* These are aliases used to explicitly state that the message should not end | * These are aliases used to explicitly state that the message should not end | ||||
* with a newline character. It allows for detecting the missing newlines that | * with a newline character. It allows for detecting the missing newlines that | ||||
* could make the logs hard to read. | * could make the logs hard to read. | ||||
*/ | */ | ||||
#define LogPrintfToBeContinued LogPrintf | #define LogPrintfToBeContinued LogPrintf | ||||
#define LogPrintToBeContinued LogPrint | #define LogPrintToBeContinued LogPrint | ||||
#endif // BITCOIN_LOGGING_H | #endif // BITCOIN_LOGGING_H |