Clang: tidy up warnings in logger

main
Adriaan de Groot 8 years ago
parent 25de3aca6e
commit 297e97da19

@ -40,6 +40,8 @@ CppJob::setModuleInstanceKey( const QString& instanceKey )
void void
CppJob::setConfigurationMap( const QVariantMap& configurationMap ) CppJob::setConfigurationMap( const QVariantMap& configurationMap )
{} {
Q_UNUSED( configurationMap );
}
} }

@ -39,9 +39,9 @@
using namespace std; using namespace std;
ofstream logfile; static ofstream logfile;
static int s_threshold = -1; static unsigned int s_threshold = 0;
QMutex s_mutex; static QMutex s_mutex;
namespace Logger namespace Logger
{ {
@ -49,20 +49,22 @@ namespace Logger
static void static void
log( const char* msg, unsigned int debugLevel, bool toDisk = true ) log( const char* msg, unsigned int debugLevel, bool toDisk = true )
{ {
if ( s_threshold < 0 ) if ( !s_threshold )
{ {
if ( qApp->arguments().contains( "--debug" ) || if ( qApp->arguments().contains( "--debug" ) ||
qApp->arguments().contains( "-d" ) ) qApp->arguments().contains( "-d" ) )
s_threshold = LOGVERBOSE; s_threshold = LOGVERBOSE;
else else
#ifdef QT_NO_DEBUG #ifdef QT_NO_DEBUG
s_threshold = RELEASE_LEVEL_THRESHOLD; s_threshold = RELEASE_LEVEL_THRESHOLD;
#else #else
s_threshold = DEBUG_LEVEL_THRESHOLD; s_threshold = DEBUG_LEVEL_THRESHOLD;
#endif #endif
// Comparison is < threshold, below
++s_threshold;
} }
if ( toDisk || (int)debugLevel <= s_threshold ) if ( toDisk || debugLevel < s_threshold )
{ {
QMutexLocker lock( &s_mutex ); QMutexLocker lock( &s_mutex );
@ -78,7 +80,7 @@ log( const char* msg, unsigned int debugLevel, bool toDisk = true )
logfile.flush(); logfile.flush();
} }
if ( debugLevel <= LOGEXTRA || (int)debugLevel <= s_threshold ) if ( debugLevel <= LOGEXTRA || debugLevel < s_threshold )
{ {
QMutexLocker lock( &s_mutex ); QMutexLocker lock( &s_mutex );
@ -96,6 +98,8 @@ CalamaresLogHandler( QtMsgType type, const QMessageLogContext& context, const QS
{ {
static QMutex s_mutex; static QMutex s_mutex;
Q_UNUSED( context );
QByteArray ba = msg.toUtf8(); QByteArray ba = msg.toUtf8();
const char* message = ba.constData(); const char* message = ba.constData();
@ -106,14 +110,12 @@ CalamaresLogHandler( QtMsgType type, const QMessageLogContext& context, const QS
log( message, LOGVERBOSE ); log( message, LOGVERBOSE );
break; break;
case QtCriticalMsg: case QtInfoMsg:
log( message, 0 ); log( message, 1 );
break; break;
case QtCriticalMsg:
case QtWarningMsg: case QtWarningMsg:
log( message, 0 );
break;
case QtFatalMsg: case QtFatalMsg:
log( message, 0 ); log( message, 0 );
break; break;

@ -52,7 +52,7 @@ namespace Logger
virtual ~CDebug(); virtual ~CDebug();
}; };
DLLEXPORT void CalamaresLogHandler( QtMsgType type, const char* msg ); DLLEXPORT void CalamaresLogHandler( QtMsgType type, const QMessageLogContext& context, const QString& msg );
DLLEXPORT void setupLogfile(); DLLEXPORT void setupLogfile();
DLLEXPORT QString logFile(); DLLEXPORT QString logFile();
} }

Loading…
Cancel
Save