Commit f4d79206 authored by Hugo Beauzée-Luyssen's avatar 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...
parent ba8571d0
...@@ -73,7 +73,7 @@ MainWindow::MainWindow( QWidget *parent ) : ...@@ -73,7 +73,7 @@ MainWindow::MainWindow( QWidget *parent ) :
m_ui.setupUi( this ); m_ui.setupUi( this );
//We only install message handler here cause it uses configuration. //We only install message handler here cause it uses configuration.
// VlmcDebug::getInstance()->setup(); VlmcDebug::getInstance()->setup();
//VLC Instance: //VLC Instance:
LibVLCpp::Instance::getInstance(); LibVLCpp::Instance::getInstance();
......
...@@ -23,13 +23,16 @@ ...@@ -23,13 +23,16 @@
#include "VLCInstance.h" #include "VLCInstance.h"
#include "vlc/vlc.h" #include "vlc/vlc.h"
#include "SettingsManager.h"
#include "VlmcDebug.h"
using namespace LibVLCpp; using namespace LibVLCpp;
Instance::Instance( QObject* parent /*= NULL*/ ) : QObject( parent ) Instance::Instance( QObject* parent /*= NULL*/ ) : QObject( parent )
{ {
char const *argv[] = char const *argv[] =
{ {
// "-vvvvv", "", //Keep this array entry empty. It will be replaced later if required.
// "--ffmpeg-debug", "3", // "--ffmpeg-debug", "3",
"--no-skip-frames", "--no-skip-frames",
// "--intf", "dummy", // "--intf", "dummy",
...@@ -42,6 +45,13 @@ Instance::Instance( QObject* parent /*= NULL*/ ) : QObject( parent ) ...@@ -42,6 +45,13 @@ Instance::Instance( QObject* parent /*= NULL*/ ) : QObject( parent )
}; };
int argc = sizeof( argv ) / sizeof( *argv ); 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 ); m_internalPtr = libvlc_new( argc, argv );
Q_ASSERT_X( m_internalPtr != NULL, "LibVLCpp::Instance::Instance()", Q_ASSERT_X( m_internalPtr != NULL, "LibVLCpp::Instance::Instance()",
"Can't launch VLMC without a valid LibVLC instance. Please check your VLC installation" ); "Can't launch VLMC without a valid LibVLC instance. Please check your VLC installation" );
......
...@@ -90,6 +90,8 @@ SettingsManager::getInstance()->createVar( type, key, defaultValue, name, \ ...@@ -90,6 +90,8 @@ SettingsManager::getInstance()->createVar( type, key, defaultValue, name, \
//Convenience maccros : //Convenience maccros :
#define VLMC_CREATE_PRIVATE_PREFERENCE_STRING( key, defaultValue ) \ #define VLMC_CREATE_PRIVATE_PREFERENCE_STRING( key, defaultValue ) \
VLMC_CREATE_PREFERENCE( SettingValue::String, key, defaultValue, "", "", SettingValue::Private ) 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 ) \ #define VLMC_CREATE_PRIVATE_PROJECT_STRING( key, defaultValue ) \
VLMC_CREATE_PROJECT_VAR( SettingValue::String, key, defaultValue, "", "", SettingValue::Private ) VLMC_CREATE_PROJECT_VAR( SettingValue::String, key, defaultValue, "", "", SettingValue::Private )
#define VLMC_CREATE_PREFERENCE_PASSWORD( key, defaultValue, name, desc ) \ #define VLMC_CREATE_PREFERENCE_PASSWORD( key, defaultValue, name, desc ) \
......
...@@ -29,24 +29,25 @@ ...@@ -29,24 +29,25 @@
VlmcDebug::VlmcDebug() : m_logFile( NULL ) VlmcDebug::VlmcDebug() : m_logFile( NULL )
{ {
//setup log level : //setup log level :
VLMC_CREATE_PRIVATE_PREFERENCE_INT( "private/LogLevel", 0 );
QStringList args = qApp->arguments(); QStringList args = qApp->arguments();
if ( args.indexOf( QRegExp( "-vvv*" ) ) >= 0 ) if ( args.indexOf( QRegExp( "-vv+" ) ) >= 0 )
SettingsManager::getInstance()->setValue( "private/LogLevel", QtDebugMsg, SettingsManager::Vlmc ); SettingsManager::getInstance()->setValue( "private/LogLevel", VlmcDebug::Debug, SettingsManager::Vlmc );
else if ( args.contains( "-v" ) == true ) else if ( args.contains( "-v" ) == true )
SettingsManager::getInstance()->setValue( "private/LogLevel", QtWarningMsg, SettingsManager::Vlmc ); SettingsManager::getInstance()->setValue( "private/LogLevel", VlmcDebug::Verbose, SettingsManager::Vlmc );
else else
SettingsManager::getInstance()->setValue( "private/LogLevel", QtCriticalMsg, SettingsManager::Vlmc ); SettingsManager::getInstance()->setValue( "private/LogLevel", VlmcDebug::Quiet, SettingsManager::Vlmc );
int pos = args.indexOf( QRegExp( "--logfile=.*" ) ); // int pos = args.indexOf( QRegExp( "--logfile=.*" ) );
if ( pos > 0 ) // if ( pos > 0 )
{ // {
QString arg = args[pos]; // QString arg = args[pos];
QString logFile = arg.mid( 10 ); // QString logFile = arg.mid( 10 );
if ( logFile.length() <= 0 ) // if ( logFile.length() <= 0 )
qWarning() << tr("Invalid value supplied for argument --logfile" ); // qWarning() << tr("Invalid value supplied for argument --logfile" );
else // else
SettingsManager::getInstance()->setValue( "private/LogFile", logFile, SettingsManager::Vlmc ); // SettingsManager::getInstance()->setValue( "private/LogFile", logFile, SettingsManager::Vlmc );
} // }
// QVariant setVal = SettingsManager::getInstance()->value( "private/LogFile", "log.vlmc", SettingsManager::Vlmc ); // QVariant setVal = SettingsManager::getInstance()->value( "private/LogFile", "log.vlmc", SettingsManager::Vlmc );
......
...@@ -38,6 +38,13 @@ class VlmcDebug : public QObject, public Singleton<VlmcDebug> ...@@ -38,6 +38,13 @@ class VlmcDebug : public QObject, public Singleton<VlmcDebug>
Q_OBJECT Q_OBJECT
public: public:
enum VerboseLevel
{
Quiet,
Verbose,
Debug
};
static void vlmcMessageHandler( QtMsgType type, const char* msg ); static void vlmcMessageHandler( QtMsgType type, const char* msg );
void setup(); void setup();
private: private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment