6 #ifndef BITCOIN_LOGGING_H
7 #define BITCOIN_LOGGING_H
68 std::list<std::string> m_msgs_before_open
GUARDED_BY(m_cs);
84 std::list<std::function<void(const std::string&)>> m_print_callbacks
GUARDED_BY(m_cs) {};
104 return m_buffering || m_print_to_console || m_print_to_file || !m_print_callbacks.empty();
108 std::list<std::function<void(const std::string&)>>::iterator
PushBackCallback(std::function<
void(
const std::string&)> fun)
111 m_print_callbacks.push_back(std::move(fun));
112 return --m_print_callbacks.end();
119 m_print_callbacks.erase(it);
165 template <
typename... Args>
166 static inline void LogPrintf(
const char* fmt,
const Args&... args)
174 log_msg =
"Error \"" + std::string(fmterr.what()) +
"\" while formatting log message: " + fmt;
182 #define LogPrint(category, ...) \
184 if (LogAcceptCategory((category))) { \
185 LogPrintf(__VA_ARGS__); \
189 #endif // BITCOIN_LOGGING_H
void EnableCategory(LogFlags flag)
FILE *m_fileout GUARDED_BY(m_cs)
std::vector< LogCategory > LogCategoriesList()
Returns a vector of the log categories.
auto Join(const std::vector< T > &list, const BaseType &separator, UnaryOp unary_op) -> decltype(unary_op(list.at(0)))
Join a list of items.
static void LogPrintf(const char *fmt, const Args &...args)
static const bool DEFAULT_LOGTHREADNAMES
uint32_t GetCategoryMask() const
static const bool DEFAULT_LOGTIMEMICROS
std::atomic< bool > m_reopen_file
BCLog::Logger & LogInstance()
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.
void LogPrintStr(const std::string &str)
Send a string to the log output.
void DisableCategory(LogFlags flag)
static bool LogAcceptCategory(BCLog::LogFlags category)
Return true if log accepts specified category.
std::atomic< uint32_t > m_categories
Log categories bitfield.
void DisconnectTestLogger()
Only for testing.
bool StartLogging()
Start logging (and flush all buffered messages)
bool WillLogCategory(LogFlags category) const
bool DefaultShrinkDebugFile() const
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...
void DeleteCallback(std::list< std::function< void(const std::string &)>>::iterator it)
Delete a connection.
std::string LogCategoriesString()
Returns a string with the log categories.
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_LOGIPS
const char *const DEFAULT_DEBUGLOGFILE
static const bool DEFAULT_LOGTIMESTAMPS
bool Enabled() const
Returns whether logs will be written to any output.
std::string LogTimestampStr(const std::string &str)