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 ) :
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();
......
......@@ -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" );
......
......@@ -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 ) \
......
......@@ -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 );
......
......@@ -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:
......
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