More logging and make it go to the right place.
authorCarl Hetherington <cth@carlh.net>
Mon, 18 May 2020 23:39:47 +0000 (01:39 +0200)
committerCarl Hetherington <cth@carlh.net>
Wed, 20 May 2020 19:56:28 +0000 (21:56 +0200)
test/4k_test.cc
test/client_server_test.cc
test/optimise_stills_test.cc
test/test.cc
test/test.h

index d8d3d66..0fe4921 100644 (file)
@@ -41,7 +41,7 @@ using boost::shared_ptr;
 BOOST_AUTO_TEST_CASE (fourk_test)
 {
        shared_ptr<Film> film = new_test_film ("4k_test");
-       dcpomatic_log = film->log ();
+       LogSwitcher ls (film->log());
        film->set_name ("4k_test");
        shared_ptr<FFmpegContent> c (new FFmpegContent("test/data/test.mp4"));
        film->set_resolution (RESOLUTION_4K);
index a64f4d2..75cee85 100644 (file)
@@ -37,6 +37,7 @@
 #include "lib/encode_server_description.h"
 #include "lib/file_log.h"
 #include "lib/dcpomatic_log.h"
+#include "test.h"
 #include <boost/test/unit_test.hpp>
 #include <boost/thread.hpp>
 
@@ -85,7 +86,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_rgb)
                p += sub_image->stride()[0];
        }
 
-       dcpomatic_log.reset (new FileLog("build/test/client_server_test_rgb.log"));
+       LogSwitcher ls (shared_ptr<Log>(new FileLog("build/test/client_server_test_rgb.log")));
 
        shared_ptr<PlayerVideo> pvf (
                new PlayerVideo (
@@ -171,7 +172,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_yuv)
                p += sub_image->stride()[0];
        }
 
-       dcpomatic_log.reset (new FileLog("build/test/client_server_test_yuv.log"));
+       LogSwitcher ls (shared_ptr<Log>(new FileLog("build/test/client_server_test_yuv.log")));
 
        shared_ptr<PlayerVideo> pvf (
                new PlayerVideo (
@@ -244,7 +245,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_j2k)
                }
        }
 
-       dcpomatic_log.reset (new FileLog("build/test/client_server_test_j2k.log"));
+       LogSwitcher ls (shared_ptr<Log>(new FileLog("build/test/client_server_test_j2k.log")));
 
        shared_ptr<PlayerVideo> raw_pvf (
                new PlayerVideo (
index d9f8d26..a57518b 100644 (file)
@@ -73,7 +73,7 @@ check (string name, int check_full, int check_repeat)
 BOOST_AUTO_TEST_CASE (optimise_stills_test1)
 {
        shared_ptr<Film> film = new_test_film ("optimise_stills_test1");
-       dcpomatic_log = film->log ();
+       LogSwitcher ls (film->log());
        film->set_container (Ratio::from_id ("185"));
        film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
        film->set_name ("frobozz");
@@ -90,7 +90,7 @@ BOOST_AUTO_TEST_CASE (optimise_stills_test1)
 BOOST_AUTO_TEST_CASE (optimise_stills_test2)
 {
        shared_ptr<Film> film = new_test_film ("optimise_stills_test2");
-       dcpomatic_log = film->log ();
+       LogSwitcher ls (film->log());
        film->set_container (Ratio::from_id ("185"));
        film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
        film->set_name ("frobozz");
index b6e017a..3ec78e6 100644 (file)
@@ -87,7 +87,7 @@ setup_test_config ()
        Config::instance()->set_default_j2k_bandwidth (100000000);
        Config::instance()->set_default_interop (false);
        Config::instance()->set_default_still_length (10);
-       Config::instance()->set_log_types (LogEntry::TYPE_GENERAL | LogEntry::TYPE_WARNING | LogEntry::TYPE_ERROR);
+       Config::instance()->set_log_types (LogEntry::TYPE_GENERAL | LogEntry::TYPE_WARNING | LogEntry::TYPE_ERROR | LogEntry::TYPE_DEBUG_THREED | LogEntry::TYPE_DEBUG_ENCODE);
        Config::instance()->set_automatic_audio_analysis (false);
 }
 
@@ -531,3 +531,17 @@ make_random_file (boost::filesystem::path path, size_t size)
        fclose (r);
        free (buffer);
 }
+
+
+LogSwitcher::LogSwitcher (shared_ptr<Log> log)
+       : _old (dcpomatic_log)
+{
+       dcpomatic_log = log;
+}
+
+
+LogSwitcher::~LogSwitcher ()
+{
+       dcpomatic_log = _old;
+}
+
index d793363..dd919b4 100644 (file)
 
 #include <Magick++.h>
 #include <boost/filesystem.hpp>
+#include <boost/shared_ptr.hpp>
 
 class Film;
 class Image;
+class Log;
 
 
 class TestPaths
@@ -51,3 +53,14 @@ boost::filesystem::path dcp_file (boost::shared_ptr<const Film> film, std::strin
 void check_one_frame (boost::filesystem::path dcp, int64_t index, boost::filesystem::path ref);
 extern boost::filesystem::path subtitle_file (boost::shared_ptr<Film> film);
 extern void make_random_file (boost::filesystem::path path, size_t size);
+
+class LogSwitcher
+{
+public:
+       LogSwitcher (boost::shared_ptr<Log> log);
+       ~LogSwitcher ();
+
+private:
+       boost::shared_ptr<Log> _old;
+};
+