mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-23 01:09:42 +01:00
* Added verbose log output for SQL queries.
This commit is contained in:
parent
5d0a54ce8b
commit
3e1a5c15c5
@ -24,6 +24,7 @@
|
||||
#include <QTime>
|
||||
|
||||
#define QUERY_THRESHOLD 60
|
||||
#define QUERY_ANALYZE 1
|
||||
|
||||
|
||||
TomahawkSqlQuery::TomahawkSqlQuery()
|
||||
@ -57,9 +58,14 @@ TomahawkSqlQuery::exec()
|
||||
showError();
|
||||
|
||||
int e = t.elapsed();
|
||||
if ( e >= QUERY_THRESHOLD )
|
||||
tLog() << "TomahawkSqlQuery (" << lastQuery() << ") finished in" << t.elapsed() << "ms";
|
||||
|
||||
bool log = ( e >= QUERY_THRESHOLD );
|
||||
#ifdef QUERY_ANALYZE
|
||||
log = true;
|
||||
#endif
|
||||
|
||||
if ( log )
|
||||
tLog( LOGSQL ) << "TomahawkSqlQuery (" << t.elapsed() << "ms ):" << lastQuery();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
|
||||
#define RELEASE_LEVEL_THRESHOLD 0
|
||||
#define DEBUG_LEVEL_THRESHOLD LOGEXTRA
|
||||
#define LOG_SQL_QUERIES 1
|
||||
|
||||
using namespace std;
|
||||
ofstream logfile;
|
||||
@ -65,9 +66,19 @@ log( const char *msg, unsigned int debugLevel, bool toDisk = true )
|
||||
if ( debugLevel > DEBUG_LEVEL_THRESHOLD )
|
||||
toDisk = false;
|
||||
#endif
|
||||
|
||||
#ifdef LOG_SQL_QUERIES
|
||||
if ( debugLevel == LOGSQL )
|
||||
toDisk = true;
|
||||
#endif
|
||||
|
||||
if ( toDisk || (int)debugLevel <= s_threshold )
|
||||
{
|
||||
#ifdef LOG_SQL_QUERIES
|
||||
if ( debugLevel == LOGSQL )
|
||||
logfile << "TSQLQUERY: ";
|
||||
#endif
|
||||
|
||||
logfile << QTime::currentTime().toString().toAscii().data() << " [" << QString::number( debugLevel ).toAscii().data() << "]: " << msg << endl;
|
||||
logfile.flush();
|
||||
}
|
||||
|
@ -24,6 +24,13 @@
|
||||
|
||||
#include "DllMacro.h"
|
||||
|
||||
#define LOGDEBUG 1
|
||||
#define LOGINFO 2
|
||||
#define LOGEXTRA 5
|
||||
#define LOGVERBOSE 8
|
||||
#define LOGTHIRDPARTY 9
|
||||
#define LOGSQL 10
|
||||
|
||||
namespace Logger
|
||||
{
|
||||
class DLLEXPORT TLog : public QDebug
|
||||
@ -40,7 +47,15 @@ namespace Logger
|
||||
class DLLEXPORT TDebug : public TLog
|
||||
{
|
||||
public:
|
||||
TDebug( unsigned int debugLevel = 1 ) : TLog( debugLevel )
|
||||
TDebug( unsigned int debugLevel = LOGDEBUG ) : TLog( debugLevel )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class DLLEXPORT TSqlLog : public TLog
|
||||
{
|
||||
public:
|
||||
TSqlLog() : TLog( LOGSQL )
|
||||
{
|
||||
}
|
||||
};
|
||||
@ -51,11 +66,6 @@ namespace Logger
|
||||
|
||||
#define tLog Logger::TLog
|
||||
#define tDebug Logger::TDebug
|
||||
|
||||
#define LOGDEBUG 1
|
||||
#define LOGINFO 2
|
||||
#define LOGEXTRA 5
|
||||
#define LOGVERBOSE 8
|
||||
#define LOGTHIRDPARTY 9
|
||||
#define tSqlLog Logger::TSqlLog
|
||||
|
||||
#endif // TOMAHAWK_LOGGER_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user