mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-22 08:52:12 +02:00
* Make tLog() work properly.
This commit is contained in:
parent
9c341bb3e6
commit
55bef176d3
@ -7,6 +7,7 @@
|
||||
#include <QFileInfo>
|
||||
#include <QMutex>
|
||||
#include <QTime>
|
||||
#include <QVariant>
|
||||
|
||||
#include "utils/tomahawkutils.h"
|
||||
|
||||
@ -19,6 +20,25 @@ ofstream logfile;
|
||||
namespace Logger
|
||||
{
|
||||
|
||||
tLog&
|
||||
tLog::operator<<( const QVariant& v )
|
||||
{
|
||||
QString const s = v.toString();
|
||||
if ( !s.isEmpty() )
|
||||
log( s.toAscii().data() );
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
tLog::log( const char *msg )
|
||||
{
|
||||
logfile << QTime::currentTime().toString().toAscii().data() << " " << msg << endl;
|
||||
logfile.flush();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkLogHandler( QtMsgType type, const char *msg )
|
||||
{
|
||||
@ -28,30 +48,27 @@ TomahawkLogHandler( QtMsgType type, const char *msg )
|
||||
switch( type )
|
||||
{
|
||||
case QtDebugMsg:
|
||||
// logfile << QTime::currentTime().toString().toAscii().data() << " Debug: " << msg << "\n";
|
||||
// Disable debug logging in release builds:
|
||||
#ifndef QT_NO_DEBUG
|
||||
tLog::log( msg );
|
||||
#endif
|
||||
break;
|
||||
|
||||
case QtCriticalMsg:
|
||||
logfile << QTime::currentTime().toString().toAscii().data() << " Critical: " << msg << endl;
|
||||
tLog::log( msg );
|
||||
break;
|
||||
|
||||
case QtWarningMsg:
|
||||
logfile << QTime::currentTime().toString().toAscii().data() << " Warning: " << msg << endl;
|
||||
tLog::log( msg );
|
||||
break;
|
||||
|
||||
case QtFatalMsg:
|
||||
logfile << QTime::currentTime().toString().toAscii().data() << " Fatal: " << msg << endl;
|
||||
logfile.flush();
|
||||
|
||||
cout << msg << endl;
|
||||
cout.flush();
|
||||
abort();
|
||||
tLog::log( msg );
|
||||
break;
|
||||
}
|
||||
|
||||
cout << msg << "\n";
|
||||
cout << msg << endl;
|
||||
cout.flush();
|
||||
logfile.flush();
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,17 +5,19 @@
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
#define tLog( PARAM ) qDebug( PARAM )
|
||||
|
||||
// Disable qDebug in release builds.
|
||||
#ifdef QT_NO_DEBUG
|
||||
#define qDebug QT_NO_QDEBUG_MACRO
|
||||
#endif
|
||||
|
||||
namespace Logger
|
||||
{
|
||||
class DLLEXPORT tLog
|
||||
{
|
||||
public:
|
||||
tLog& operator<<( const QVariant& v );
|
||||
static void log( const char *msg );
|
||||
};
|
||||
|
||||
DLLEXPORT void TomahawkLogHandler( QtMsgType type, const char *msg );
|
||||
DLLEXPORT void setupLogfile();
|
||||
}
|
||||
|
||||
#define tLog Logger::tLog
|
||||
|
||||
#endif
|
@ -138,16 +138,14 @@ TomahawkApp::init()
|
||||
new TomahawkSettings( this );
|
||||
TomahawkSettings* s = TomahawkSettings::instance();
|
||||
|
||||
#ifdef LIBLASTFM_FOUND
|
||||
qDebug() << "Setting NAM.";
|
||||
#ifdef LIBLASTFM_FOUND
|
||||
TomahawkUtils::setNam( lastfm::nam() );
|
||||
#else
|
||||
qDebug() << "Setting NAM.";
|
||||
#else
|
||||
TomahawkUtils::setNam( new QNetworkAccessManager() );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
TomahawkUtils::NetworkProxyFactory* proxyFactory = new TomahawkUtils::NetworkProxyFactory();
|
||||
|
||||
if ( s->proxyType() != QNetworkProxy::NoProxy && !s->proxyHost().isEmpty() )
|
||||
{
|
||||
qDebug() << "Setting proxy to saved values";
|
||||
@ -156,7 +154,6 @@ TomahawkApp::init()
|
||||
//TODO: On Windows and Mac because liblastfm sets an application level proxy it may override our factory, so may need to explicitly do
|
||||
//a QNetworkProxy::setApplicationProxy with our own proxy (but then also overriding our own factory :-( )
|
||||
}
|
||||
|
||||
if ( !s->proxyNoProxyHosts().isEmpty() )
|
||||
proxyFactory->setNoProxyHosts( s->proxyNoProxyHosts().split( ',', QString::SkipEmptyParts ) );
|
||||
|
||||
@ -244,7 +241,7 @@ TomahawkApp::init()
|
||||
|
||||
TomahawkApp::~TomahawkApp()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
tLog() << "Shutting down Tomahawk...";
|
||||
|
||||
// stop script resolvers
|
||||
foreach( Tomahawk::ExternalResolver* r, m_scriptResolvers.values() )
|
||||
@ -280,7 +277,7 @@ TomahawkApp::~TomahawkApp()
|
||||
Pipeline::instance()->stop();
|
||||
delete Pipeline::instance();
|
||||
|
||||
qDebug() << "Finished shutdown.";
|
||||
tLog() << "Finished shutdown.";
|
||||
}
|
||||
|
||||
|
||||
@ -323,6 +320,7 @@ TomahawkApp::registerMetaTypes()
|
||||
|
||||
qRegisterMetaType< GeneratorMode>("GeneratorMode");
|
||||
qRegisterMetaType<Tomahawk::GeneratorMode>("Tomahawk::GeneratorMode");
|
||||
|
||||
// Extra definition for namespaced-versions of signals/slots required
|
||||
qRegisterMetaType< Tomahawk::source_ptr >("Tomahawk::source_ptr");
|
||||
qRegisterMetaType< Tomahawk::collection_ptr >("Tomahawk::collection_ptr");
|
||||
@ -389,7 +387,7 @@ TomahawkApp::initHTTP()
|
||||
Api_v1* api = new Api_v1( &m_session );
|
||||
m_session.setStaticContentService( api );
|
||||
|
||||
qDebug() << "Starting HTTPd on" << m_session.listenInterface().toString() << m_session.port();
|
||||
tLog() << "Starting HTTPd on" << m_session.listenInterface().toString() << m_session.port();
|
||||
m_session.start();
|
||||
|
||||
}
|
||||
@ -477,7 +475,7 @@ TomahawkApp::initServent()
|
||||
int port = TomahawkSettings::instance()->externalPort();
|
||||
if ( !Servent::instance()->startListening( QHostAddress( QHostAddress::Any ), upnp, port ) )
|
||||
{
|
||||
qDebug() << "Failed to start listening with servent";
|
||||
tLog() << "Failed to start listening with servent";
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
@ -486,8 +484,6 @@ TomahawkApp::initServent()
|
||||
void
|
||||
TomahawkApp::initSIP()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
//FIXME: jabber autoconnect is really more, now that there is sip -- should be renamed and/or split out of jabber-specific settings
|
||||
if ( !arguments().contains( "--nosip" ) )
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user