From 8f7fdb9fdcd4ffd076f07de9f49801fe01991776 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 15 Feb 2019 00:56:23 +0000 Subject: [PATCH] Add support for player logging. --- src/lib/config.cc | 12 +++++++++--- src/lib/config.h | 19 +++++++++++++++++++ src/tools/dcpomatic_player.cc | 17 ++++++++++++++--- src/wx/player_config_dialog.cc | 15 +++++++++++++++ 4 files changed, 57 insertions(+), 6 deletions(-) diff --git a/src/lib/config.cc b/src/lib/config.cc index ac7cf7e76..bf4b49552 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -169,6 +169,7 @@ Config::set_defaults () _image_display = 0; _respect_kdm_validity_periods = true; _player_activity_log_file = boost::none; + _player_debug_log_file = boost::none; _player_content_directory = boost::none; _player_playlist_directory = boost::none; _player_kdm_directory = boost::none; @@ -555,6 +556,7 @@ try if (!_player_activity_log_file) { _player_activity_log_file = f.optional_string_child("PlayerActivityLogFile"); } + _player_debug_log_file = f.optional_string_child("PlayerDebugLogFile"); _player_content_directory = f.optional_string_child("PlayerContentDirectory"); _player_playlist_directory = f.optional_string_child("PlayerPlaylistDirectory"); _player_kdm_directory = f.optional_string_child("PlayerKDMDirectory"); @@ -997,16 +999,20 @@ Config::write_config () const /* [XML] PlayerLogFile Filename to use for player activity logs (e.g starting, stopping, playlist loads) */ root->add_child("PlayerActivityLogFile")->add_child_text(_player_activity_log_file->string()); } + if (_player_debug_log_file) { + /* [XML] PlayerLogFile Filename to use for player debug logs */ + root->add_child("PlayerDebugLogFile")->add_child_text(_player_debug_log_file->string()); + } if (_player_content_directory) { - /* [XML] PlayerContentDirectory Filename to use for player content in the dual-screen mode. */ + /* [XML] PlayerContentDirectory Directory to use for player content in the dual-screen mode. */ root->add_child("PlayerContentDirectory")->add_child_text(_player_content_directory->string()); } if (_player_playlist_directory) { - /* [XML] PlayerPlaylistDirectory Filename to use for player playlists in the dual-screen mode. */ + /* [XML] PlayerPlaylistDirectory Directory to use for player playlists in the dual-screen mode. */ root->add_child("PlayerPlaylistDirectory")->add_child_text(_player_playlist_directory->string()); } if (_player_kdm_directory) { - /* [XML] PlayerKDMDirectory Filename to use for player KDMs in the dual-screen mode. */ + /* [XML] PlayerKDMDirectory Directory to use for player KDMs in the dual-screen mode. */ root->add_child("PlayerKDMDirectory")->add_child_text(_player_kdm_directory->string()); } #ifdef DCPOMATIC_VARIANT_SWAROOP diff --git a/src/lib/config.h b/src/lib/config.h index 5ae14ebda..21463fdb5 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -79,6 +79,7 @@ public: INTERFACE_COMPLEXITY, PLAYER_CONTENT_DIRECTORY, PLAYER_PLAYLIST_DIRECTORY, + PLAYER_DEBUG_LOG, HISTORY, #ifdef DCPOMATIC_VARIANT_SWAROOP PLAYER_BACKGROUND_IMAGE, @@ -488,6 +489,10 @@ public: return _player_activity_log_file; } + boost::optional player_debug_log_file () const { + return _player_debug_log_file; + } + boost::optional player_content_directory () const { return _player_content_directory; } @@ -952,6 +957,18 @@ public: changed (); } + void set_player_debug_log_file (boost::filesystem::path p) { + maybe_set (_player_debug_log_file, p, PLAYER_DEBUG_LOG); + } + + void unset_player_debug_log_file () { + if (!_player_debug_log_file) { + return; + } + _player_debug_log_file = boost::none; + changed (PLAYER_DEBUG_LOG); + } + void set_player_content_directory (boost::filesystem::path p) { maybe_set (_player_content_directory, p, PLAYER_CONTENT_DIRECTORY); } @@ -1231,6 +1248,8 @@ private: playlist etc.) Does not contain debugging information. */ boost::optional _player_activity_log_file; + /** Log file containing debug information for the player */ + boost::optional _player_debug_log_file; /** A directory containing DCPs whose contents are presented to the user in the dual-screen player mode. DCPs on the list can be loaded for playback. diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc index 793600001..1cc53dafb 100644 --- a/src/tools/dcpomatic_player.cc +++ b/src/tools/dcpomatic_player.cc @@ -53,6 +53,7 @@ #include "lib/lock_file_checker.h" #include "lib/ffmpeg_content.h" #include "lib/dcpomatic_log.h" +#include "lib/file_log.h" #include #include #include @@ -147,7 +148,7 @@ public: #endif _config_changed_connection = Config::instance()->Changed.connect (boost::bind (&DOMFrame::config_changed, this, _1)); - update_from_config (); + update_from_config (Config::PLAYER_DEBUG_LOG); Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_open, this), ID_file_open); Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_add_ov, this), ID_file_add_ov); @@ -826,10 +827,10 @@ private: ); } - update_from_config (); + update_from_config (prop); } - void update_from_config () + void update_from_config (Config::Property prop) { for (int i = 0; i < _history_items; ++i) { delete _file_menu->Remove (ID_file_history + i); @@ -860,6 +861,16 @@ private: } _history_items = history.size (); + + if (prop == Config::PLAYER_DEBUG_LOG) { + optional p = Config::instance()->player_debug_log_file(); + if (p) { + dcpomatic_log.reset (new FileLog(*p)); + } else { + dcpomatic_log.reset (new NullLog()); + } + dcpomatic_log->set_types (LogEntry::TYPE_GENERAL | LogEntry::TYPE_WARNING | LogEntry::TYPE_ERROR); + } } void set_menu_sensitivity () diff --git a/src/wx/player_config_dialog.cc b/src/wx/player_config_dialog.cc index b4a4ee4f4..ef58bab00 100644 --- a/src/wx/player_config_dialog.cc +++ b/src/wx/player_config_dialog.cc @@ -111,6 +111,11 @@ private: table->Add (_activity_log_file, wxGBPosition(r, 1)); ++r; + add_label_to_sizer (table, _panel, _("Debug log file"), true, wxGBPosition (r, 0)); + _debug_log_file = new FilePickerCtrl (_panel, _("Select debug log file"), "*", true); + table->Add (_debug_log_file, wxGBPosition(r, 1)); + ++r; + #ifdef DCPOMATIC_VARIANT_SWAROOP add_label_to_sizer (table, _panel, _("KDM server URL"), true, wxGBPosition(r, 0)); _kdm_server_url = new wxTextCtrl (_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(400, -1)); @@ -127,6 +132,7 @@ private: _image_display->Bind (wxEVT_CHOICE, bind(&PlayerGeneralPage::image_display_changed, this)); _respect_kdm->Bind (wxEVT_CHECKBOX, bind(&PlayerGeneralPage::respect_kdm_changed, this)); _activity_log_file->Bind (wxEVT_FILEPICKER_CHANGED, bind(&PlayerGeneralPage::activity_log_file_changed, this)); + _debug_log_file->Bind (wxEVT_FILEPICKER_CHANGED, bind(&PlayerGeneralPage::debug_log_file_changed, this)); #ifdef DCPOMATIC_VARIANT_SWAROOP _kdm_server_url->Bind (wxEVT_TEXT, bind(&PlayerGeneralPage::kdm_server_url_changed, this)); _lock_file->Bind (wxEVT_FILEPICKER_CHANGED, bind(&PlayerGeneralPage::lock_file_changed, this)); @@ -156,6 +162,9 @@ private: if (config->player_activity_log_file()) { checked_set (_activity_log_file, *config->player_activity_log_file()); } + if (config->player_debug_log_file()) { + checked_set (_debug_log_file, *config->player_debug_log_file()); + } #ifdef DCPOMATIC_VARIANT_SWAROOP checked_set (_kdm_server_url, config->kdm_server_url()); if (config->player_lock_file()) { @@ -195,6 +204,11 @@ private: Config::instance()->set_player_activity_log_file(wx_to_std(_activity_log_file->GetPath())); } + void debug_log_file_changed () + { + Config::instance()->set_player_debug_log_file(wx_to_std(_debug_log_file->GetPath())); + } + #ifdef DCPOMATIC_VARIANT_SWAROOP void kdm_server_url_changed () { @@ -211,6 +225,7 @@ private: wxChoice* _image_display; wxCheckBox* _respect_kdm; FilePickerCtrl* _activity_log_file; + FilePickerCtrl* _debug_log_file; #ifdef DCPOMATIC_VARIANT_SWAROOP wxTextCtrl* _kdm_server_url; FilePickerCtrl* _lock_file; -- 2.30.2