Add ASDCPErrorSuspender to hide errors from asdcplib where we expect them.
authorCarl Hetherington <cth@carlh.net>
Thu, 3 Sep 2020 10:01:34 +0000 (12:01 +0200)
committerCarl Hetherington <cth@carlh.net>
Sun, 20 Sep 2020 17:32:42 +0000 (19:32 +0200)
src/util.cc
src/util.h

index f755c21e5903f3ae55df23d6004393eee10b42cf..c7d090eaa016764411e8e44e935bc1a63d0a9c99 100644 (file)
@@ -427,3 +427,20 @@ dcp::unique_string (list<string> existing, string base)
 
        DCP_ASSERT (false);
 }
+
+
+ASDCPErrorSuspender::ASDCPErrorSuspender ()
+       : _old (Kumu::DefaultLogSink())
+{
+       _sink = new Kumu::EntryListLogSink(_log);
+       Kumu::SetDefaultLogSink (_sink);
+}
+
+
+ASDCPErrorSuspender::~ASDCPErrorSuspender ()
+{
+       Kumu::SetDefaultLogSink (&_old);
+       delete _sink;
+}
+
+
index b66832654d02812da85ef9e04b908df11831395c..a14d7364bbfbef381bf9b1e49cd05236534e22b1 100644 (file)
@@ -41,6 +41,7 @@
 #include "types.h"
 #include "data.h"
 #include "local_time.h"
+#include <asdcp/KM_log.h>
 #include <boost/shared_ptr.hpp>
 #include <boost/function.hpp>
 #include <boost/filesystem.hpp>
@@ -82,6 +83,20 @@ extern bool day_less_than_or_equal (LocalTime a, LocalTime b);
 extern bool day_greater_than_or_equal (LocalTime a, LocalTime b);
 extern std::string unique_string (std::list<std::string> existing, std::string base);
 
+
+class ASDCPErrorSuspender
+{
+public:
+       ASDCPErrorSuspender();
+       ~ASDCPErrorSuspender();
+
+private:
+       Kumu::LogEntryList _log;
+       Kumu::ILogSink& _old;
+       Kumu::EntryListLogSink* _sink;
+};
+
+
 }
 
 #endif