More logging tweaks; allow log level to be specified on the command line; bump libdcp...
authorCarl Hetherington <cth@carlh.net>
Thu, 6 Dec 2012 21:40:56 +0000 (21:40 +0000)
committerCarl Hetherington <cth@carlh.net>
Thu, 6 Dec 2012 21:40:56 +0000 (21:40 +0000)
run/dvdomatic
src/lib/ffmpeg_decoder.cc
src/lib/log.cc
src/lib/log.h
src/tools/dvdomatic.cc
wscript

index 125fd9d27223f324de4899e2f1e15bc0537cba78..70906a2546b8f276d0065cc40f37d4d28632713b 100755 (executable)
@@ -3,10 +3,10 @@
 export LD_LIBRARY_PATH=build/src/lib:build/src/wx:build/src/asdcplib/src:$LD_LIBRARY_PATH
 if [ "$1" == "--debug" ]; then
     shift
-    gdb --args build/src/tools/dvdomatic "$1"
+    gdb --args build/src/tools/dvdomatic $*
 elif [ "$1" == "--valgrind" ]; then
     shift
-    valgrind --tool="memcheck" build/src/tools/dvdomatic "$1"
+    valgrind --tool="memcheck" build/src/tools/dvdomatic $*
 else
-    build/src/tools/dvdomatic "$1"
+    build/src/tools/dvdomatic $*
 fi
index 49e03b1cebe6c15e12614603ed59340a72f6f058..9b89ffffcbcfbeb5f7573b626bdd2106b9b070d7 100644 (file)
@@ -279,7 +279,7 @@ FFmpegDecoder::pass ()
 
                        _film->log()->log (
                                String::compose ("Source video frame ready; source at %1, output at %2", source_pts_seconds, out_pts_seconds),
-                               Log::DEBUG
+                               Log::VERBOSE
                                );
 
                        if (!_first_video) {
index 650384bc7726986ff97800613f0ef09f2a41346f..06cff04956b8b1a28fde9ff31c493def5a5930f7 100644 (file)
@@ -76,6 +76,19 @@ Log::set_level (Level l)
        _level = l;
 }
 
+void
+Log::set_level (string l)
+{
+       if (l == "verbose") {
+               set_level (VERBOSE);
+               return;
+       } else if (l == "timing") {
+               set_level (TIMING);
+               return;
+       }
+
+       set_level (STANDARD);
+}
 
 /** @param file Filename to write log to */
 FileLog::FileLog (string file)
index c5241ebcf9607d38055cbd5cfe9b96be01bf7c70..3a2cfcbfd53e7882a61feaa03268738036a60b1f 100644 (file)
@@ -37,16 +37,16 @@ public:
        virtual ~Log () {}
 
        enum Level {
-               SILENT = 0,
+               STANDARD = 0,
                VERBOSE = 1,
-               DEBUG = 2,
-               TIMING = 3
+               TIMING = 2
        };
 
        void log (std::string m, Level l = STANDARD);
        void microsecond_log (std::string m, Level l = STANDARD);
 
        void set_level (Level l);
+       void set_level (std::string l);
 
 protected:     
        /** mutex to protect the log */
index 7700a38ef5514c69b7276222da35d0eac5270c12..88c03d753576c1aa7173d19ede723a416991cc54 100644 (file)
@@ -40,7 +40,9 @@
 #include "lib/exceptions.h"
 #include "lib/version.h"
 #include "lib/ui_signaller.h"
+#include "lib/log.h"
 
+using std::cout;
 using std::string;
 using std::stringstream;
 using std::map;
@@ -49,8 +51,9 @@ using boost::shared_ptr;
 
 static FilmEditor* film_editor = 0;
 static FilmViewer* film_viewer = 0;
-
 static shared_ptr<Film> film;
+static std::string log_level;
+static std::string film_to_load;
 
 static void set_menu_sensitivity ();
 
@@ -267,6 +270,7 @@ public:
                        
                        maybe_save_then_delete_film ();
                        film.reset (new Film (d->get_path (), false));
+                       film->log()->set_level (log_level);
 #if BOOST_FILESYSTEM_VERSION == 3              
                        film->set_name (boost::filesystem::path (d->get_path()).filename().generic_string());
 #else          
@@ -286,6 +290,7 @@ public:
                if (r == wxID_OK) {
                        maybe_save_then_delete_film ();
                        film.reset (new Film (wx_to_std (c->GetPath ())));
+                       film->log()->set_level (log_level);
                        set_film ();
                }
 
@@ -356,10 +361,20 @@ public:
        }
 };
 
+static const wxCmdLineEntryDesc command_line_description[] = {
+       { wxCMD_LINE_OPTION, wxT("l"), wxT("log"), wxT("set log level (silent, verbose or timing)"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
+        { wxCMD_LINE_PARAM, 0, 0, wxT("film to load"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE | wxCMD_LINE_PARAM_OPTIONAL },
+       { wxCMD_LINE_NONE }
+};
+
 class App : public wxApp
 {
        bool OnInit ()
        {
+               if (!wxApp::OnInit()) {
+                       return false;
+               }
+               
 #ifdef DVDOMATIC_POSIX         
                unsetenv ("UBUNTU_MENUPROXY");
 #endif         
@@ -368,8 +383,9 @@ class App : public wxApp
                
                dvdomatic_setup ();
 
-               if (argc == 2 && boost::filesystem::is_directory (wx_to_std (argv[1]))) {
-                       film.reset (new Film (wx_to_std (argv[1])));
+               if (!film_to_load.empty() && boost::filesystem::is_directory (film_to_load)) {
+                       film.reset (new Film (film_to_load));
+                       film->log()->set_level (log_level);
                }
 
                Frame* f = new Frame (_("DVD-o-matic"));
@@ -383,6 +399,26 @@ class App : public wxApp
                return true;
        }
 
+       void OnInitCmdLine (wxCmdLineParser& parser)
+       {
+               parser.SetDesc (command_line_description);
+               parser.SetSwitchChars (wxT ("-"));
+       }
+
+       bool OnCmdLineParsed (wxCmdLineParser& parser)
+       {
+               if (parser.GetParamCount() > 0) {
+                       film_to_load = wx_to_std (parser.GetParam(0));
+               }
+
+               wxString log;
+               if (parser.Found(wxT("log"), &log)) {
+                       log_level = wx_to_std (log);
+               }
+
+               return true;
+       }
+
        void idle (wxIdleEvent &)
        {
                ui_signaller->ui_idle ();
diff --git a/wscript b/wscript
index c255993d2ed5817eecfdd6f7adc13bf8a3c09e37..ee307202657dae733a6dd169d3a4c5a56f6c6b80 100644 (file)
--- a/wscript
+++ b/wscript
@@ -54,7 +54,7 @@ def configure(conf):
     conf.check_cfg(package = 'libswresample', args = '--cflags --libs', uselib_store = 'SWRESAMPLE', mandatory = False)
     conf.check_cfg(package = 'libpostproc', args = '--cflags --libs', uselib_store = 'POSTPROC', mandatory = True)
     conf.check_cfg(package = 'sndfile', args = '--cflags --libs', uselib_store = 'SNDFILE', mandatory = True)
-    conf.check_cfg(package = 'libdcp', atleast_version = '0.32', args = '--cflags --libs', uselib_store = 'DCP', mandatory = True)
+    conf.check_cfg(package = 'libdcp', atleast_version = '0.33', args = '--cflags --libs', uselib_store = 'DCP', mandatory = True)
     conf.check_cfg(package = 'glib-2.0', args = '--cflags --libs', uselib_store = 'GLIB', mandatory = True)
     conf.check_cfg(package = '', path = 'Magick++-config', args = '--cppflags --cxxflags --libs', uselib_store = 'MAGICK', mandatory = True)
     conf.check_cc(fragment  = """