[vlmc-devel] commit: VLC debug level can now be set through the command line. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Mon Oct 11 01:10:31 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Mon Oct 11 01:09:34 2010 +0200| [f4d792068750583b777049bacf230b5142b28ee2] | committer: Hugo Beauzée-Luyssen 

VLC debug level can now be set through the command line.

This will ease the pain when asking a user to enable vlc's log...

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=f4d792068750583b777049bacf230b5142b28ee2
---

 src/Gui/MainWindow.cpp         |    2 +-
 src/LibVLCpp/VLCInstance.cpp   |   12 +++++++++++-
 src/Settings/SettingsManager.h |    2 ++
 src/Tools/VlmcDebug.cpp        |   29 +++++++++++++++--------------
 src/Tools/VlmcDebug.h          |    7 +++++++
 5 files changed, 36 insertions(+), 16 deletions(-)

diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp
index 96e057d..eaf40f1 100644
--- a/src/Gui/MainWindow.cpp
+++ b/src/Gui/MainWindow.cpp
@@ -73,7 +73,7 @@ MainWindow::MainWindow( QWidget *parent ) :
     m_ui.setupUi( this );
 
     //We only install message handler here cause it uses configuration.
-//    VlmcDebug::getInstance()->setup();
+    VlmcDebug::getInstance()->setup();
 
     //VLC Instance:
     LibVLCpp::Instance::getInstance();
diff --git a/src/LibVLCpp/VLCInstance.cpp b/src/LibVLCpp/VLCInstance.cpp
index 96717e5..61a64d9 100644
--- a/src/LibVLCpp/VLCInstance.cpp
+++ b/src/LibVLCpp/VLCInstance.cpp
@@ -23,13 +23,16 @@
 #include "VLCInstance.h"
 #include "vlc/vlc.h"
 
+#include "SettingsManager.h"
+#include "VlmcDebug.h"
+
 using namespace LibVLCpp;
 
 Instance::Instance( QObject* parent /*= NULL*/ ) : QObject( parent )
 {
     char const *argv[] =
     {
-//        "-vvvvv",
+        "", //Keep this array entry empty. It will be replaced later if required.
 //        "--ffmpeg-debug", "3",
         "--no-skip-frames",
 //        "--intf", "dummy",
@@ -42,6 +45,13 @@ Instance::Instance( QObject* parent /*= NULL*/ ) : QObject( parent )
     };
     int argc = sizeof( argv ) / sizeof( *argv );
 
+    int     debugLevel = VLMC_GET_INT( "private/LogLevel" );
+    qDebug() << debugLevel;
+    if ( debugLevel == VlmcDebug::Debug )
+        argv[0] = "-vv";
+    else if ( debugLevel == VlmcDebug::Verbose )
+        argv[0] = "-v";
+
     m_internalPtr = libvlc_new( argc, argv );
     Q_ASSERT_X( m_internalPtr != NULL, "LibVLCpp::Instance::Instance()",
                 "Can't launch VLMC without a valid LibVLC instance. Please check your VLC installation" );
diff --git a/src/Settings/SettingsManager.h b/src/Settings/SettingsManager.h
index 3bbf1ee..65975ee 100644
--- a/src/Settings/SettingsManager.h
+++ b/src/Settings/SettingsManager.h
@@ -90,6 +90,8 @@ SettingsManager::getInstance()->createVar( type, key, defaultValue, name,  \
 //Convenience maccros :
 #define VLMC_CREATE_PRIVATE_PREFERENCE_STRING( key, defaultValue )  \
         VLMC_CREATE_PREFERENCE( SettingValue::String, key, defaultValue, "", "", SettingValue::Private )
+#define VLMC_CREATE_PRIVATE_PREFERENCE_INT( key, defaultValue )  \
+        VLMC_CREATE_PREFERENCE( SettingValue::Int, key, defaultValue, "", "", SettingValue::Private )
 #define VLMC_CREATE_PRIVATE_PROJECT_STRING( key, defaultValue )  \
         VLMC_CREATE_PROJECT_VAR( SettingValue::String, key, defaultValue, "", "", SettingValue::Private )
 #define VLMC_CREATE_PREFERENCE_PASSWORD( key, defaultValue, name, desc )  \
diff --git a/src/Tools/VlmcDebug.cpp b/src/Tools/VlmcDebug.cpp
index 9bbbe9d..6adb3ec 100644
--- a/src/Tools/VlmcDebug.cpp
+++ b/src/Tools/VlmcDebug.cpp
@@ -29,24 +29,25 @@
 VlmcDebug::VlmcDebug() : m_logFile( NULL )
 {
     //setup log level :
+    VLMC_CREATE_PRIVATE_PREFERENCE_INT( "private/LogLevel", 0 );
     QStringList args = qApp->arguments();
-    if ( args.indexOf( QRegExp( "-vvv*" ) ) >= 0 )
-        SettingsManager::getInstance()->setValue( "private/LogLevel", QtDebugMsg, SettingsManager::Vlmc );
+    if ( args.indexOf( QRegExp( "-vv+" ) ) >= 0 )
+        SettingsManager::getInstance()->setValue( "private/LogLevel", VlmcDebug::Debug, SettingsManager::Vlmc );
     else if ( args.contains( "-v" ) == true )
-        SettingsManager::getInstance()->setValue( "private/LogLevel", QtWarningMsg, SettingsManager::Vlmc );
+        SettingsManager::getInstance()->setValue( "private/LogLevel", VlmcDebug::Verbose, SettingsManager::Vlmc );
     else
-        SettingsManager::getInstance()->setValue( "private/LogLevel", QtCriticalMsg, SettingsManager::Vlmc );
+        SettingsManager::getInstance()->setValue( "private/LogLevel", VlmcDebug::Quiet, SettingsManager::Vlmc );
 
-    int pos = args.indexOf( QRegExp( "--logfile=.*" ) );
-    if ( pos > 0 )
-    {
-        QString arg = args[pos];
-        QString logFile = arg.mid( 10 );
-        if ( logFile.length() <= 0 )
-            qWarning() << tr("Invalid value supplied for argument --logfile" );
-        else
-            SettingsManager::getInstance()->setValue( "private/LogFile", logFile, SettingsManager::Vlmc );
-    }
+//    int pos = args.indexOf( QRegExp( "--logfile=.*" ) );
+//    if ( pos > 0 )
+//    {
+//        QString arg = args[pos];
+//        QString logFile = arg.mid( 10 );
+//        if ( logFile.length() <= 0 )
+//            qWarning() << tr("Invalid value supplied for argument --logfile" );
+//        else
+//            SettingsManager::getInstance()->setValue( "private/LogFile", logFile, SettingsManager::Vlmc );
+//    }
 
 
 //    QVariant setVal = SettingsManager::getInstance()->value( "private/LogFile", "log.vlmc", SettingsManager::Vlmc );
diff --git a/src/Tools/VlmcDebug.h b/src/Tools/VlmcDebug.h
index 2f4eee7..85ba9c5 100644
--- a/src/Tools/VlmcDebug.h
+++ b/src/Tools/VlmcDebug.h
@@ -38,6 +38,13 @@ class   VlmcDebug : public QObject, public Singleton<VlmcDebug>
     Q_OBJECT
 
     public:
+        enum    VerboseLevel
+        {
+            Quiet,
+            Verbose,
+            Debug
+        };
+
         static void     vlmcMessageHandler( QtMsgType type, const char* msg );
         void            setup();
     private:



More information about the Vlmc-devel mailing list