From cd5ed3bbb45fc41e2c414276477eed2448d5a699 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 1 May 2022 20:45:48 +0200 Subject: [PATCH] Log errors from asdcplib in our logs. --- src/lib/util.cc | 30 ++++++++++++++++++++++++++++++ src/lib/util.h | 1 + 2 files changed, 31 insertions(+) diff --git a/src/lib/util.cc b/src/lib/util.cc index c964d8533..ed0de7595 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -34,6 +34,7 @@ #include "cross.h" #include "crypto.h" #include "dcp_content_type.h" +#include "dcpomatic_log.h" #include "digester.h" #include "exceptions.h" #include "ffmpeg_image_proxy.h" @@ -424,6 +425,8 @@ LIBDCP_ENABLE_WARNINGS curl_global_init (CURL_GLOBAL_ALL); ui_thread = boost::this_thread::get_id (); + + capture_asdcp_logs (); } #ifdef DCPOMATIC_WINDOWS @@ -1148,3 +1151,30 @@ start_of_thread (string) } #endif + +class LogSink : public Kumu::ILogSink +{ +public: + LogSink () {} + LogSink (LogSink const&) = delete; + LogSink& operator= (LogSink const&) = delete; + + void WriteEntry(const Kumu::LogEntry& entry) override { + Kumu::AutoMutex L(m_lock); + WriteEntryToListeners(entry); + if (entry.TestFilter(m_filter)) { + string buffer; + entry.CreateStringWithOptions(buffer, m_options); + LOG_GENERAL("asdcplib: %1", buffer); + } + } +}; + + +void +capture_asdcp_logs () +{ + static LogSink log_sink; + Kumu::SetDefaultLogSink(&log_sink); +} + diff --git a/src/lib/util.h b/src/lib/util.h index 5878d5937..fba5b6828 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -125,6 +125,7 @@ extern dcp::DecryptedKDM decrypt_kdm_with_helpful_error (dcp::EncryptedKDM kdm); extern boost::filesystem::path default_font_file (); extern std::string to_upper (std::string s); extern void start_of_thread (std::string name); +extern void capture_asdcp_logs (); template std::list -- 2.30.2