From: Carl Hetherington Date: Mon, 18 May 2020 23:39:47 +0000 (+0200) Subject: More logging and make it go to the right place. X-Git-Tag: v2.15.76~20 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=6eec3fea764f2fe35723089d60c51005616905bf More logging and make it go to the right place. --- diff --git a/test/4k_test.cc b/test/4k_test.cc index d8d3d66ec..0fe492133 100644 --- a/test/4k_test.cc +++ b/test/4k_test.cc @@ -41,7 +41,7 @@ using boost::shared_ptr; BOOST_AUTO_TEST_CASE (fourk_test) { shared_ptr film = new_test_film ("4k_test"); - dcpomatic_log = film->log (); + LogSwitcher ls (film->log()); film->set_name ("4k_test"); shared_ptr c (new FFmpegContent("test/data/test.mp4")); film->set_resolution (RESOLUTION_4K); diff --git a/test/client_server_test.cc b/test/client_server_test.cc index a64f4d295..75cee85b3 100644 --- a/test/client_server_test.cc +++ b/test/client_server_test.cc @@ -37,6 +37,7 @@ #include "lib/encode_server_description.h" #include "lib/file_log.h" #include "lib/dcpomatic_log.h" +#include "test.h" #include #include @@ -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(new FileLog("build/test/client_server_test_rgb.log"))); shared_ptr 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(new FileLog("build/test/client_server_test_yuv.log"))); shared_ptr 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(new FileLog("build/test/client_server_test_j2k.log"))); shared_ptr raw_pvf ( new PlayerVideo ( diff --git a/test/optimise_stills_test.cc b/test/optimise_stills_test.cc index d9f8d262a..a57518b2d 100644 --- a/test/optimise_stills_test.cc +++ b/test/optimise_stills_test.cc @@ -73,7 +73,7 @@ check (string name, int check_full, int check_repeat) BOOST_AUTO_TEST_CASE (optimise_stills_test1) { shared_ptr 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 = 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"); diff --git a/test/test.cc b/test/test.cc index b6e017acd..3ec78e68b 100644 --- a/test/test.cc +++ b/test/test.cc @@ -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) + : _old (dcpomatic_log) +{ + dcpomatic_log = log; +} + + +LogSwitcher::~LogSwitcher () +{ + dcpomatic_log = _old; +} + diff --git a/test/test.h b/test/test.h index d793363d5..dd919b408 100644 --- a/test/test.h +++ b/test/test.h @@ -20,9 +20,11 @@ #include #include +#include class Film; class Image; +class Log; class TestPaths @@ -51,3 +53,14 @@ boost::filesystem::path dcp_file (boost::shared_ptr 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); extern void make_random_file (boost::filesystem::path path, size_t size); + +class LogSwitcher +{ +public: + LogSwitcher (boost::shared_ptr log); + ~LogSwitcher (); + +private: + boost::shared_ptr _old; +}; +