mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
logging: Add member for arbitrary print callbacks
This commit is contained in:
@@ -67,6 +67,9 @@ bool BCLog::Logger::StartLogging()
|
||||
|
||||
if (m_print_to_file) FileWriteStr(s, m_fileout);
|
||||
if (m_print_to_console) fwrite(s.data(), 1, s.size(), stdout);
|
||||
for (const auto& cb : m_print_callbacks) {
|
||||
cb(s);
|
||||
}
|
||||
|
||||
m_msgs_before_open.pop_front();
|
||||
}
|
||||
@@ -81,6 +84,7 @@ void BCLog::Logger::DisconnectTestLogger()
|
||||
m_buffering = true;
|
||||
if (m_fileout != nullptr) fclose(m_fileout);
|
||||
m_fileout = nullptr;
|
||||
m_print_callbacks.clear();
|
||||
}
|
||||
|
||||
void BCLog::Logger::EnableCategory(BCLog::LogFlags flag)
|
||||
@@ -270,6 +274,9 @@ void BCLog::Logger::LogPrintStr(const std::string& str)
|
||||
fwrite(str_prefixed.data(), 1, str_prefixed.size(), stdout);
|
||||
fflush(stdout);
|
||||
}
|
||||
for (const auto& cb : m_print_callbacks) {
|
||||
cb(str_prefixed);
|
||||
}
|
||||
if (m_print_to_file) {
|
||||
assert(m_fileout != nullptr);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user