mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-21 16:29:43 +01:00
* Expose logfile's path in Logger.
This commit is contained in:
parent
5f907258eb
commit
81b9af0dc9
@ -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
|
||||
@ -98,7 +97,7 @@ log( const char *msg, unsigned int debugLevel, bool toDisk = true )
|
||||
|
||||
|
||||
void
|
||||
TomahawkLogHandler( QtMsgType type, const char *msg )
|
||||
TomahawkLogHandler( QtMsgType type, const char* msg )
|
||||
{
|
||||
static QMutex s_mutex;
|
||||
|
||||
@ -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.write( lc.right( LOGFILE_SIZE - ( LOGFILE_SIZE / 4 ) ) );
|
||||
f.close();
|
||||
}
|
||||
}
|
||||
|
||||
logfile.open( LOGFILE, ios::app );
|
||||
logfile.open( logFile().toLocal8Bit(), ios::app );
|
||||
qInstallMsgHandler( TomahawkLogHandler );
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ namespace Logger
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class DLLEXPORT TSqlLog : public TLog
|
||||
{
|
||||
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 QString logFile();
|
||||
}
|
||||
|
||||
#define tLog Logger::TLog
|
||||
|
Loading…
x
Reference in New Issue
Block a user