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