summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-10-23 12:35:07 +0200
committerCarl Hetherington <cth@carlh.net>2025-10-23 12:35:09 +0200
commit0ae0428494f6f3d23ac8224561b73607f524b32c (patch)
treea8f48f3bec5b595cd7eaac5f168734d1b6f5293a
parentce596021e11ea3b579f759436d66c43ac107d3d1 (diff)
Remove log handling from Film.
It should be the main UI's responsibility to set up dcpomatic_log, maybe writing it to the film's directory if it wants to.
-rw-r--r--src/lib/create_cli.cc3
-rw-r--r--src/lib/encode_cli.cc3
-rw-r--r--src/lib/film.cc8
-rw-r--r--src/lib/film.h9
-rw-r--r--src/lib/job.cc4
-rw-r--r--src/lib/player.cc4
-rw-r--r--src/lib/send_problem_report_job.cc3
-rw-r--r--src/tools/dcpomatic.cc13
-rw-r--r--test/4k_test.cc1
-rw-r--r--test/optimise_stills_test.cc2
10 files changed, 18 insertions, 32 deletions
diff --git a/src/lib/create_cli.cc b/src/lib/create_cli.cc
index af2e90745..eccd2d1da 100644
--- a/src/lib/create_cli.cc
+++ b/src/lib/create_cli.cc
@@ -27,6 +27,7 @@
#include "dcp_content.h"
#include "dcp_content_type.h"
#include "dcpomatic_log.h"
+#include "file_log.h"
#include "film.h"
#include "image_content.h"
#include "guess_crop.h"
@@ -447,7 +448,7 @@ shared_ptr<Film>
CreateCLI::make_film(function<void (string)> error) const
{
auto film = std::make_shared<Film>(output_dir);
- dcpomatic_log = film->log();
+ dcpomatic_log = make_shared<FileLog>(film->file("log"));
dcpomatic_log->set_types(Config::instance()->log_types());
if (_template_name) {
film->use_template(_template_name.get());
diff --git a/src/lib/encode_cli.cc b/src/lib/encode_cli.cc
index 8bf1a4a26..91fc7ee29 100644
--- a/src/lib/encode_cli.cc
+++ b/src/lib/encode_cli.cc
@@ -26,6 +26,7 @@
#include "dcpomatic_log.h"
#include "encode_server_finder.h"
#include "ffmpeg_film_encoder.h"
+#include "file_log.h"
#include "film.h"
#include "filter.h"
#ifdef DCPOMATIC_GROK
@@ -518,7 +519,7 @@ encode_cli(int argc, char* argv[], function<void (string)> out, function<void ()
return {};
}
- dcpomatic_log = film->log();
+ dcpomatic_log = make_shared<FileLog>(film->file("log"));
for (auto i: film->content()) {
auto paths = i->paths();
diff --git a/src/lib/film.cc b/src/lib/film.cc
index c6a6f3cce..f726b2549 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -43,14 +43,12 @@
#include "exceptions.h"
#include "ffmpeg_content.h"
#include "ffmpeg_subtitle_stream.h"
-#include "file_log.h"
#include "film.h"
#include "film_util.h"
#include "font.h"
#include "job.h"
#include "job_manager.h"
#include "kdm_with_metadata.h"
-#include "null_log.h"
#include "playlist.h"
#include "ratio.h"
#include "screen.h"
@@ -221,12 +219,6 @@ Film::Film(optional<boost::filesystem::path> dir)
_directory = dcp::filesystem::weakly_canonical(*dir);
}
- if (_directory) {
- _log = make_shared<FileLog>(file("log"));
- } else {
- _log = make_shared<NullLog>();
- }
-
_playlist->set_sequence(_sequence);
}
diff --git a/src/lib/film.h b/src/lib/film.h
index 8574c700f..08f639db9 100644
--- a/src/lib/film.h
+++ b/src/lib/film.h
@@ -109,13 +109,6 @@ public:
void send_dcp_to_tms();
- /** @return Logger.
- * It is safe to call this from any thread.
- */
- std::shared_ptr<Log> log() const {
- return _log;
- }
-
boost::filesystem::path file(boost::filesystem::path f) const;
boost::filesystem::path dir(boost::filesystem::path d, bool create = true) const;
@@ -486,8 +479,6 @@ private:
void check_reel_boundaries_for_atmos();
std::vector<dcpomatic::DCPTimePeriod> reels_for_type(ReelType type) const;
- /** Log to write to */
- std::shared_ptr<Log> _log;
std::shared_ptr<Playlist> _playlist;
/** Complete path to directory containing the film metadata;
diff --git a/src/lib/job.cc b/src/lib/job.cc
index ab4f5c37a..70f4cd9f0 100644
--- a/src/lib/job.cc
+++ b/src/lib/job.cc
@@ -556,9 +556,7 @@ Job::error_summary() const
void
Job::set_error(string s, string d)
{
- if (_film) {
- _film->log()->log(fmt::format("Error in job: {} ({})", s, d), LogEntry::TYPE_ERROR);
- }
+ dcpomatic_log->log(fmt::format("Error in job: {} ({})", s, d), LogEntry::TYPE_ERROR);
boost::mutex::scoped_lock lm(_state_mutex);
_error_summary = s;
diff --git a/src/lib/player.cc b/src/lib/player.cc
index 985bd3a9c..743d17fcb 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -802,7 +802,7 @@ Player::pass()
/* Let's not worry about less than a frame at 24fps */
int64_t const too_much_error = DCPTime::from_frames(1, 24).get();
if (error >= too_much_error) {
- film->log()->log(fmt::format("Silence starting before or after last audio by {}", error), LogEntry::TYPE_ERROR);
+ dcpomatic_log->log(fmt::format("Silence starting before or after last audio by {}", error), LogEntry::TYPE_ERROR);
}
DCPOMATIC_ASSERT(error < too_much_error);
period.from = *_next_audio_time;
@@ -1470,7 +1470,7 @@ Player::emit_audio(shared_ptr<AudioBuffers> data, DCPTime time)
/* Log if the assert below is about to fail */
if (_next_audio_time && labs(time.get() - _next_audio_time->get()) > 1) {
- film->log()->log(fmt::format("Out-of-sequence emit {} vs {}", to_string(time), to_string(*_next_audio_time)), LogEntry::TYPE_WARNING);
+ dcpomatic_log->log(fmt::format("Out-of-sequence emit {} vs {}", to_string(time), to_string(*_next_audio_time)), LogEntry::TYPE_WARNING);
}
/* This audio must follow on from the previous, allowing for half a sample (at 48kHz) leeway */
diff --git a/src/lib/send_problem_report_job.cc b/src/lib/send_problem_report_job.cc
index 5d62bb4d1..eff1f797e 100644
--- a/src/lib/send_problem_report_job.cc
+++ b/src/lib/send_problem_report_job.cc
@@ -20,6 +20,7 @@
#include "cross.h"
+#include "dcpomatic_log.h"
#include "email.h"
#include "environment_info.h"
#include "film.h"
@@ -98,7 +99,7 @@ SendProblemReportJob::run ()
if (_film) {
body += "log head and tail:\n";
body += "---<8----\n";
- body += _film->log()->head_and_tail (4096);
+ body += dcpomatic_log->head_and_tail(4096);
body += "---<8----\n\n";
add_file (body, "ffprobe.log");
diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc
index e0c69f5a4..f5994913a 100644
--- a/src/tools/dcpomatic.cc
+++ b/src/tools/dcpomatic.cc
@@ -77,6 +77,7 @@
#include "lib/encode_server_finder.h"
#include "lib/exceptions.h"
#include "lib/ffmpeg_film_encoder.h"
+#include "lib/file_log.h"
#include "lib/film.h"
#include "lib/font_config.h"
#ifdef DCPOMATIC_GROK
@@ -87,6 +88,7 @@
#include "lib/kdm_with_metadata.h"
#include "lib/log.h"
#include "lib/make_dcp.h"
+#include "lib/null_log.h"
#include "lib/release_notes.h"
#include "lib/screen.h"
#include "lib/send_kdm_email_job.h"
@@ -520,14 +522,17 @@ public:
_controls->set_film (_film);
_video_waveform_dialog.reset();
set_menu_sensitivity ();
- if (_film && _film->directory()) {
- Config::instance()->add_to_history (_film->directory().get());
- }
if (_film) {
+ if (_film->directory()) {
+ Config::instance()->add_to_history(_film->directory().get());
+ dcpomatic_log = make_shared<FileLog>(_film->file("log"));
+ } else {
+ dcpomatic_log = make_shared<NullLog>();
+ }
+
_film->Change.connect (boost::bind (&DOMFrame::film_change, this, _1));
_film->Message.connect (boost::bind(&DOMFrame::film_message, this, _1));
_film->DirtyChange.connect (boost::bind(&DOMFrame::set_title, this));
- dcpomatic_log = _film->log ();
}
set_title ();
}
diff --git a/test/4k_test.cc b/test/4k_test.cc
index a1b9477b1..562dc1188 100644
--- a/test/4k_test.cc
+++ b/test/4k_test.cc
@@ -46,7 +46,6 @@ BOOST_AUTO_TEST_CASE (fourk_test)
{
auto c = make_shared<FFmpegContent>("test/data/test.mp4");
auto film = new_test_film("4k_test", { c });
- LogSwitcher ls (film->log());
film->set_resolution (Resolution::FOUR_K);
film->set_dcp_content_type(DCPContentType::from_isdcf_name("FTR"));
diff --git a/test/optimise_stills_test.cc b/test/optimise_stills_test.cc
index c0049507d..996119841 100644
--- a/test/optimise_stills_test.cc
+++ b/test/optimise_stills_test.cc
@@ -76,7 +76,6 @@ BOOST_AUTO_TEST_CASE (optimise_stills_test1)
{
auto content = content_factory("test/data/flat_red.png")[0];
auto film = new_test_film("optimise_stills_test1", { content });
- LogSwitcher ls (film->log());
make_and_verify_dcp (film);
check ("optimise_stills_test1", 1, 10 * 24 - 1);
@@ -88,7 +87,6 @@ BOOST_AUTO_TEST_CASE (optimise_stills_test2)
{
auto content = content_factory("test/data/flat_red.png")[0];
auto film = new_test_film("optimise_stills_test2", { content });
- LogSwitcher ls (film->log());
content->video->set_frame_type (VideoFrameType::THREE_D_LEFT_RIGHT);
film->set_three_d (true);
make_and_verify_dcp (film);