7 #ifndef BITCOIN_LOGGING_H
8 #define BITCOIN_LOGGING_H
65 #ifdef DEBUG_LOCKCONTENTION
97 std::list<std::function<void(
const std::string &)>>
116 const std::string &logging_function,
117 const std::string &source_file,
const int source_line);
123 !m_print_callbacks.empty();
127 std::list<std::function<void(
const std::string &)>>::iterator
130 m_print_callbacks.push_back(std::move(fun));
131 return --m_print_callbacks.end();
136 std::list<std::function<
void(
const std::string &)>>::iterator it) {
138 m_print_callbacks.erase(it);
185 template <
typename... Args>
187 LogPrintf_(
const std::string &logging_function,
const std::string &source_file,
188 const int source_line,
const char *fmt,
const Args &...args) {
197 log_msg =
"Error \"" + std::string(fmterr.what()) +
198 "\" while formatting log message: " + fmt;
205 #define LogPrintf(...) LogPrintf_(__func__, __FILE__, __LINE__, __VA_ARGS__)
209 #define LogPrint(category, ...) \
211 if (LogAcceptCategory((category))) { \
212 LogPrintf(__VA_ARGS__); \
221 #define LogPrintfToBeContinued LogPrintf
222 #define LogPrintToBeContinued LogPrint
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.
std::list< std::function< void(const std::string &)> >::iterator PushBackCallback(std::function< void(const std::string &)> fun)
Connect a slot to the print signal and return the connection.
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::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::list< std::function< void(const std::string &)> > m_print_callbacks GUARDED_BY(m_cs)
Slots that connect to the print signal.
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)
FILE *m_fileout GUARDED_BY(m_cs)
void DeleteCallback(std::list< std::function< void(const std::string &)>>::iterator it)
Delete a connection.
std::atomic< bool > m_reopen_file
uint32_t GetCategoryMask() const
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.
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
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
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
BCLog::Logger & LogInstance()
auto Join(const std::vector< T > &list, const BaseType &separator, UnaryOp unary_op) -> decltype(unary_op(list.at(0)))
Join a list of items.