aboutsummaryrefslogtreecommitdiff
path: root/src/logging.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2019-09-26 13:31:57 -0400
committerMarcoFalke <falke.marco@gmail.com>2019-11-04 10:42:29 -0500
commitfa1936f57bbf5aebb1f8fc18701441d79219d443 (patch)
tree82b944a2f5ad061909217366ed6bfe403eab654c /src/logging.cpp
parentfba574c908bb61eff1a0e83c935f3526ba9035f2 (diff)
logging: Add member for arbitrary print callbacks
Diffstat (limited to 'src/logging.cpp')
-rw-r--r--src/logging.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/logging.cpp b/src/logging.cpp
index 60ab486198..b01177f23f 100644
--- a/src/logging.cpp
+++ b/src/logging.cpp
@@ -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);