From 08db8ff8a9875fe98acfd4746af293dfcc1087c2 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 3 Sep 2020 12:01:34 +0200 Subject: Add ASDCPErrorSuspender to hide errors from asdcplib where we expect them. --- src/util.cc | 17 +++++++++++++++++ src/util.h | 15 +++++++++++++++ 2 files changed, 32 insertions(+) (limited to 'src') diff --git a/src/util.cc b/src/util.cc index f755c21e..c7d090ea 100644 --- a/src/util.cc +++ b/src/util.cc @@ -427,3 +427,20 @@ dcp::unique_string (list 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; +} + + diff --git a/src/util.h b/src/util.h index b6683265..a14d7364 100644 --- a/src/util.h +++ b/src/util.h @@ -41,6 +41,7 @@ #include "types.h" #include "data.h" #include "local_time.h" +#include #include #include #include @@ -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 existing, std::string base); + +class ASDCPErrorSuspender +{ +public: + ASDCPErrorSuspender(); + ~ASDCPErrorSuspender(); + +private: + Kumu::LogEntryList _log; + Kumu::ILogSink& _old; + Kumu::EntryListLogSink* _sink; +}; + + } #endif -- cgit v1.2.3