1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 22:26:32 +02:00

* Mutex protect logging.

This commit is contained in:
Christian Muehlhaeuser
2012-06-24 11:16:20 +02:00
parent 9171de999b
commit 0a3a9a7e97

View File

@@ -38,8 +38,10 @@
#define LOG_SQL_QUERIES 1 #define LOG_SQL_QUERIES 1
using namespace std; using namespace std;
ofstream logfile; ofstream logfile;
static int s_threshold = -1; static int s_threshold = -1;
QMutex s_mutex;
namespace Logger namespace Logger
{ {
@@ -74,6 +76,8 @@ log( const char *msg, unsigned int debugLevel, bool toDisk = true )
if ( toDisk || (int)debugLevel <= s_threshold ) if ( toDisk || (int)debugLevel <= s_threshold )
{ {
QMutexLocker lock( &s_mutex );
#ifdef LOG_SQL_QUERIES #ifdef LOG_SQL_QUERIES
if ( debugLevel == LOGSQL ) if ( debugLevel == LOGSQL )
logfile << "TSQLQUERY: "; logfile << "TSQLQUERY: ";
@@ -85,6 +89,8 @@ log( const char *msg, unsigned int debugLevel, bool toDisk = true )
if ( debugLevel <= LOGEXTRA || (int)debugLevel <= s_threshold ) if ( debugLevel <= LOGEXTRA || (int)debugLevel <= s_threshold )
{ {
QMutexLocker lock( &s_mutex );
cout << msg << endl; cout << msg << endl;
cout.flush(); cout.flush();
} }