Add support for player logging. v2.13.119
authorCarl Hetherington <cth@carlh.net>
Fri, 15 Feb 2019 00:56:23 +0000 (00:56 +0000)
committerCarl Hetherington <cth@carlh.net>
Fri, 15 Feb 2019 00:56:23 +0000 (00:56 +0000)
src/lib/config.cc
src/lib/config.h
src/tools/dcpomatic_player.cc
src/wx/player_config_dialog.cc

index ac7cf7e7653cb97cfc725abec2c03dc57838fb40..bf4b495523cd10433e3b80549fd5ac7db67ff279 100644 (file)
@@ -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
index 5ae14ebda03384f8250f3ad12d4085fd4025aa62..21463fdb5bc44500ca16827acbfc6f766ee06b7c 100644 (file)
@@ -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<boost::filesystem::path> player_debug_log_file () const {
+               return _player_debug_log_file;
+       }
+
        boost::optional<boost::filesystem::path> 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<boost::filesystem::path> _player_activity_log_file;
+       /** Log file containing debug information for the player */
+       boost::optional<boost::filesystem::path> _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.
index 793600001145b96bf87f5d22734fa0e24b0e0916..1cc53dafba2f6cf9aa95c52e39208f8576dab7dd 100644 (file)
@@ -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 <dcp/dcp.h>
 #include <dcp/raw_convert.h>
 #include <dcp/exceptions.h>
@@ -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<boost::filesystem::path> 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 ()
index b4a4ee4f4006dd08b45cf4468aaa04fba9342487..ef58bab001fb01f82ae371892890b91e0f1f4636 100644 (file)
@@ -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;