7#ifndef BITCOIN_LOGGING_H
8#define BITCOIN_LOGGING_H
99 std::list<std::function<
void(
const std::string &)>>
129 std::list<std::function<
void(
const std::string &)>>::iterator
138 std::list<std::function<
void(
const std::string &)>>::iterator it) {
187template <
typename... Args>
200 "\" while formatting log message: " +
fmt;
207#define LogPrintf(...) LogPrintf_(__func__, __FILE__, __LINE__, __VA_ARGS__)
211#define LogPrint(category, ...) \
213 if (LogAcceptCategory((category))) { \
214 LogPrintf(__VA_ARGS__); \
223#define LogPrintfToBeContinued LogPrintf
224#define LogPrintToBeContinued LogPrint
226template <
typename... Args>
bool error(
const char *
fmt,
const Args &...args) {
FILE *m_fileout GUARDED_BY(m_cs)
bool m_buffering GUARDED_BY(m_cs)
Buffer messages before logging can be started.
bool WillLogCategory(LogFlags category) const
Return true if log accepts specified category.
bool Enabled() const
Returns whether logs will be written to any output.
std::string LogTimestampStr(const std::string &str)
void DisconnectTestLogger()
Only for testing.
std::list< std::function< void(conststd::string &)> >::iterator PushBackCallback(std::function< void(const std::string &)> fun)
Connect a slot to the print signal and return the connection.
std::list< std::string > m_msgs_before_open GUARDED_BY(m_cs)
std::atomic< uint32_t > m_categories
Log categories bitfield.
bool DefaultShrinkDebugFile() const
Default for whether ShrinkDebugFile should be run.
bool m_log_sourcelocations
std::atomic_bool m_started_new_line
m_started_new_line is a state variable that will suppress printing of the timestamp when multiple cal...
std::vector< LogCategory > LogCategoriesList() const
Returns a vector of the log categories in alphabetical order.
void DisableCategory(LogFlags category)
void EnableCategory(LogFlags category)
bool StartLogging()
Start logging (and flush all buffered messages)
std::atomic< bool > m_reopen_file
uint32_t GetCategoryMask() const
std::list< std::function< void(const std::string &)> > m_print_callbacks GUARDED_BY(m_cs)
Slots that connect to the print signal.
void LogPrintStr(const std::string &str, const std::string &logging_function, const std::string &source_file, const int source_line)
Send a string to the log output.
std::string LogCategoriesString() const
Returns a string with the log categories in alphabetical order.
void DeleteCallback(std::list< std::function< void(const std::string &)> >::iterator it)
Delete a connection.
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
bool error(const char *fmt, const Args &...args)
static const bool DEFAULT_LOGTIMESTAMPS
static bool LogAcceptCategory(BCLog::LogFlags category)
Return true if log accepts specified category.
static void LogPrintf_(const std::string &logging_function, const std::string &source_file, const int source_line, const char *fmt, const Args &...args)
static const bool DEFAULT_LOGIPS
static const bool DEFAULT_LOGTHREADNAMES
BCLog::Logger & LogInstance()
bool GetLogCategory(BCLog::LogFlags &flag, const std::string &str)
Return true if str parses as a log category and set the flag.
static const bool DEFAULT_LOGSOURCELOCATIONS
static const bool DEFAULT_LOGTIMEMICROS
const char *const DEFAULT_DEBUGLOGFILE
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
auto Join(const std::vector< T > &list, const BaseType &separator, UnaryOp unary_op) -> decltype(unary_op(list.at(0)))
Join a list of items.