@ -2,7 +2,7 @@
*
* Copyright 2010 - 2011 , Christian Muehlhaeuser < muesli @ tomahawk - player . org >
* Copyright 2014 , Teo Mrnjavac < teo @ kde . org >
* Copyright 2017 , Adriaan de Groot < groot @ kde . org >
* Copyright 2017 - 2018 , Adriaan de Groot < groot @ kde . org >
*
* Calamares is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
@ -34,13 +34,8 @@
# define LOGFILE_SIZE 1024 * 256
# define RELEASE_LEVEL_THRESHOLD 0
# define DEBUG_LEVEL_THRESHOLD LOGEXTRA
using namespace std ;
static ofstream logfile ;
static unsigned int s_threshold = 0 ;
static std : : ofstream logfile ;
static unsigned int s_threshold = 0 ; // Set to non-zero on first logging call
static QMutex s_mutex ;
namespace Logger
@ -56,9 +51,9 @@ log( const char* msg, unsigned int debugLevel, bool toDisk = true )
s_threshold = LOGVERBOSE ;
else
# ifdef QT_NO_DEBUG
s_threshold = RELEASE_LEVEL_THRESHOLD ;
s_threshold = LOG_DISABLE ;
# else
s_threshold = DEBUG_LEVEL_THRESHOLD ;
s_threshold = LOGEXTRA ;
# endif
// Comparison is < threshold, below
+ + s_threshold ;
@ -75,7 +70,7 @@ log( const char* msg, unsigned int debugLevel, bool toDisk = true )
< < " - "
< < QTime : : currentTime ( ) . toString ( ) . toUtf8 ( ) . data ( )
< < " [ " < < QString : : number ( debugLevel ) . toUtf8 ( ) . data ( ) < < " ]: "
< < msg < < endl;
< < msg < < std: : endl;
logfile . flush ( ) ;
}
@ -84,11 +79,10 @@ log( const char* msg, unsigned int debugLevel, bool toDisk = true )
{
QMutexLocker lock ( & s_mutex ) ;
cout < < QTime : : currentTime ( ) . toString ( ) . toUtf8 ( ) . data ( )
std: : cout < < QTime : : currentTime ( ) . toString ( ) . toUtf8 ( ) . data ( )
< < " [ " < < QString : : number ( debugLevel ) . toUtf8 ( ) . data ( ) < < " ]: "
< < msg < < endl ;
cout . flush ( ) ;
< < msg < < std : : endl ;
std : : cout . flush ( ) ;
}
}
@ -155,7 +149,7 @@ setupLogfile()
cDebug ( ) < < " Using log file: " < < logFile ( ) ;
logfile . open ( logFile ( ) . toLocal8Bit ( ) , ios: : app ) ;
logfile . open ( logFile ( ) . toLocal8Bit ( ) , std: : ios: : app ) ;
qInstallMessageHandler ( CalamaresLogHandler ) ;
}