mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 06:07:37 +02:00
* Expose logfile's path in Logger.
This commit is contained in:
@@ -30,7 +30,6 @@
|
|||||||
|
|
||||||
#include "utils/TomahawkUtils.h"
|
#include "utils/TomahawkUtils.h"
|
||||||
|
|
||||||
#define LOGFILE TomahawkUtils::appLogDir().filePath( "Tomahawk.log" ).toLocal8Bit()
|
|
||||||
#define LOGFILE_SIZE 1024 * 256
|
#define LOGFILE_SIZE 1024 * 256
|
||||||
|
|
||||||
#define RELEASE_LEVEL_THRESHOLD 0
|
#define RELEASE_LEVEL_THRESHOLD 0
|
||||||
@@ -98,7 +97,7 @@ log( const char *msg, unsigned int debugLevel, bool toDisk = true )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TomahawkLogHandler( QtMsgType type, const char *msg )
|
TomahawkLogHandler( QtMsgType type, const char* msg )
|
||||||
{
|
{
|
||||||
static QMutex s_mutex;
|
static QMutex s_mutex;
|
||||||
|
|
||||||
@@ -124,30 +123,37 @@ TomahawkLogHandler( QtMsgType type, const char *msg )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString
|
||||||
|
logFile()
|
||||||
|
{
|
||||||
|
return TomahawkUtils::appLogDir().filePath( "Tomahawk.log" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
setupLogfile()
|
setupLogfile()
|
||||||
{
|
{
|
||||||
if ( QFileInfo( LOGFILE ).size() > LOGFILE_SIZE )
|
if ( QFileInfo( logFile().toLocal8Bit() ).size() > LOGFILE_SIZE )
|
||||||
{
|
{
|
||||||
QByteArray lc;
|
QByteArray lc;
|
||||||
{
|
{
|
||||||
QFile f( LOGFILE );
|
QFile f( logFile().toLocal8Bit() );
|
||||||
f.open( QIODevice::ReadOnly | QIODevice::Text );
|
f.open( QIODevice::ReadOnly | QIODevice::Text );
|
||||||
lc = f.readAll();
|
lc = f.readAll();
|
||||||
f.close();
|
f.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile::remove( LOGFILE );
|
QFile::remove( logFile().toLocal8Bit() );
|
||||||
|
|
||||||
{
|
{
|
||||||
QFile f( LOGFILE );
|
QFile f( logFile().toLocal8Bit() );
|
||||||
f.open( QIODevice::WriteOnly | QIODevice::Text );
|
f.open( QIODevice::WriteOnly | QIODevice::Text );
|
||||||
f.write( lc.right( LOGFILE_SIZE - (LOGFILE_SIZE / 4) ) );
|
f.write( lc.right( LOGFILE_SIZE - ( LOGFILE_SIZE / 4 ) ) );
|
||||||
f.close();
|
f.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logfile.open( LOGFILE, ios::app );
|
logfile.open( logFile().toLocal8Bit(), ios::app );
|
||||||
qInstallMsgHandler( TomahawkLogHandler );
|
qInstallMsgHandler( TomahawkLogHandler );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -51,7 +51,7 @@ namespace Logger
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class DLLEXPORT TSqlLog : public TLog
|
class DLLEXPORT TSqlLog : public TLog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -60,8 +60,9 @@ namespace Logger
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
DLLEXPORT void TomahawkLogHandler( QtMsgType type, const char *msg );
|
DLLEXPORT void TomahawkLogHandler( QtMsgType type, const char* msg );
|
||||||
DLLEXPORT void setupLogfile();
|
DLLEXPORT void setupLogfile();
|
||||||
|
DLLEXPORT QString logFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
#define tLog Logger::TLog
|
#define tLog Logger::TLog
|
||||||
|
Reference in New Issue
Block a user