Log errors from asdcplib in our logs.
authorCarl Hetherington <cth@carlh.net>
Sun, 1 May 2022 18:45:48 +0000 (20:45 +0200)
committerCarl Hetherington <cth@carlh.net>
Mon, 13 Jun 2022 22:19:48 +0000 (00:19 +0200)
src/lib/util.cc
src/lib/util.h

index c964d853330ac5a7876f50919c22463fab54db17..ed0de75959578cdd5016118c6c27f23c1d913b8a 100644 (file)
@@ -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);
+}
+
index 5878d5937ed3deeee8a65af5a2f8024f7cb3d414..fba5b6828855f9d3a7968bcea3c561e35b34ff26 100644 (file)
@@ -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 <class T>
 std::list<T>