6#ifndef BITCOIN_LOGGING_H
7#define BITCOIN_LOGGING_H
90 std::list<std::function<void(
const std::string&)>> m_print_callbacks
GUARDED_BY(
m_cs) {};
105 void LogPrintStr(
const std::string& str,
const std::string& logging_function,
const std::string& source_file,
const int source_line);
115 std::list<std::function<void(
const std::string&)>>::iterator
PushBackCallback(std::function<
void(
const std::string&)> fun)
118 m_print_callbacks.push_back(std::move(fun));
119 return --m_print_callbacks.end();
123 void DeleteCallback(std::list<std::function<
void(
const std::string&)>>::iterator it)
126 m_print_callbacks.erase(it);
172template <
typename... Args>
173static inline void LogPrintf_(
const std::string& logging_function,
const std::string& source_file,
const int source_line,
const char* fmt,
const Args&... args)
181 log_msg =
"Error \"" + std::string(fmterr.what()) +
"\" while formatting log message: " + fmt;
187#define LogPrintf(...) LogPrintf_(__func__, __FILE__, __LINE__, __VA_ARGS__)
191#define LogPrint(category, ...) \
193 if (LogAcceptCategory((category))) { \
194 LogPrintf(__VA_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
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
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 EnableCategory(LogFlags flag)
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.
void DisableCategory(LogFlags flag)
Path class wrapper to prepare application code for transition from boost::filesystem library to std::...
static const bool DEFAULT_LOGTIMESTAMPS
static void LogPrintf_(const std::string &logging_function, const std::string &source_file, const int source_line, const char *fmt, const Args &... args)
static bool LogAcceptCategory(BCLog::LogFlags category)
Return true if log accepts specified category.
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
auto Join(const std::vector< T > &list, const BaseType &separator, UnaryOp unary_op) -> decltype(unary_op(list.at(0)))
Join a list of items.