6 #ifndef BITCOIN_LOGGING_H 7 #define BITCOIN_LOGGING_H 68 std::list<std::string> m_msgs_before_open
GUARDED_BY(m_cs);
76 std::atomic_bool m_started_new_line{
true};
79 std::atomic<uint32_t> m_categories{0};
81 std::string LogTimestampStr(
const std::string& str);
84 std::list<std::function<void(const std::string&)>> m_print_callbacks
GUARDED_BY(m_cs) {};
87 bool m_print_to_console =
false;
88 bool m_print_to_file =
false;
95 std::atomic<bool> m_reopen_file{
false};
98 void LogPrintStr(
const std::string& str);
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);
125 void DisconnectTestLogger();
127 void ShrinkDebugFile();
132 bool EnableCategory(
const std::string& str);
133 void DisableCategory(
LogFlags flag);
134 bool DisableCategory(
const std::string& str);
138 std::vector<LogCategory> LogCategoriesList()
const;
145 bool DefaultShrinkDebugFile()
const;
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
std::deque< CInv >::iterator it
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 const bool DEFAULT_LOGTHREADNAMES
static const bool DEFAULT_LOGTIMEMICROS
static void LogPrintf(const char *fmt, const Args &... args)
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.
uint32_t GetCategoryMask() const
bool WillLogCategory(LogFlags category) const
static bool LogAcceptCategory(BCLog::LogFlags category)
Return true if log accepts specified category.
std::list< std::function< void(const std::string &)> > m_print_callbacks GUARDED_BY(m_cs)
Slots that connect to the print signal.
void DeleteCallback(std::list< std::function< void(const std::string &)>>::iterator it)
Delete a connection.
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
bool Enabled() const
Returns whether logs will be written to any output.
static const bool DEFAULT_LOGTIMESTAMPS
std::string LogCategoriesString() const
Returns a string with the log categories.