21 #include <QApplication>
26 #include "qgsconfig.h"
28 #ifndef CMAKE_SOURCE_DIR
29 #error CMAKE_SOURCE_DIR undefined
30 #endif // CMAKE_SOURCE_DIR
32 int QgsLogger::sDebugLevel = -999;
33 int QgsLogger::sPrefixLength = -1;
36 QTime QgsLogger::sTime;
38 void QgsLogger::init()
40 if ( sDebugLevel != -999 )
45 sLogFile = getenv(
"QGIS_LOG_FILE" ) ? getenv(
"QGIS_LOG_FILE" ) :
"";
46 sFileFilter = getenv(
"QGIS_DEBUG_FILE" ) ? getenv(
"QGIS_DEBUG_FILE" ) :
"";
47 sDebugLevel = getenv(
"QGIS_DEBUG" ) ? atoi( getenv(
"QGIS_DEBUG" ) ) :
55 sPrefixLength =
sizeof( CMAKE_SOURCE_DIR );
56 if ( CMAKE_SOURCE_DIR[sPrefixLength-1] ==
'/' )
67 if ( sDebugLevel == 0 || debuglevel > sDebugLevel )
98 m.
prepend( file + sPrefixLength );
116 debug(
QString(
"%1: %2" ).arg( var ).arg( val ), debuglevel, file,
function, line );
121 debug(
QString(
"%1: %2" ).arg( var ).arg( val ), debuglevel, file,
function, line );
148 QFile file( sLogFile );
149 if ( !file.
open( QIODevice::Append ) )
static void critical(const QString &msg)
Goes to qCritical.
QString & prepend(QChar ch)
static void warning(const QString &msg)
Goes to qWarning.
const char * constData() const
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const
static void logMessageToFile(QString theMessage)
Logs the message passed in to the logfile defined in QGIS_LOG_FILE if any.
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
static void fatal(const QString &msg)
Goes to qFatal.
QByteArray toLocal8Bit() const
static void debug(const QString &msg, int debuglevel=1, const char *file=NULL, const char *function=NULL, int line=-1)
Goes to qDebug.
QThread * currentThread()
qint64 write(const char *data, qint64 maxSize)