24 #include "qgsconfig.h"
26 #ifndef CMAKE_SOURCE_DIR
27 #error CMAKE_SOURCE_DIR undefinied
28 #endif // CMAKE_SOURCE_DIR
33 void QgsLogger::debug(
const QString& msg,
int debuglevel,
const char*
file,
const char*
function,
int line )
38 if ( !file || strncmp( dfile, file, strlen( dfile ) ) != 0 )
45 if ( dlevel >= debuglevel && debuglevel > 0 )
55 m = QString(
"%1: %2" ).arg( file +
sPrefixLength ).arg( msg );
57 else if ( line == -1 )
59 m = QString(
"%1: (%2) %3" ).arg( file +
sPrefixLength ).arg(
function ).arg( msg );
64 m = QString(
"%1: %2: (%3) %4" ).arg( file +
sPrefixLength ).arg( line ).arg(
function ).arg( msg );
66 m = QString(
"%1(%2) : (%3) %4" ).arg( file ).arg( line ).arg(
function ).arg( msg );
71 qDebug(
"%s", m.toLocal8Bit().constData() );
80 void QgsLogger::debug(
const QString& var,
int val,
int debuglevel,
const char*
file,
const char*
function,
int line )
85 if ( !file || strncmp( dfile, file, strlen( dfile ) ) != 0 )
92 if ( dlevel >= debuglevel && debuglevel > 0 )
96 qDebug(
"%s: %d", var.toLocal8Bit().constData(), val );
97 logMessageToFile( QString(
"%s: %d" ).arg( var.toLocal8Bit().constData() ).arg( val ) );
101 qDebug(
"%s: %s: %d", file +
sPrefixLength, var.toLocal8Bit().constData(), val );
104 else if ( line == -1 )
106 qDebug(
"%s: (%s): %s: %d", file +
sPrefixLength,
function, var.toLocal8Bit().constData(), val );
107 logMessageToFile( QString(
"%s: (%s): %s: %d" ).arg( file +
sPrefixLength ).arg(
function ).arg( var.toLocal8Bit().constData() ).arg( val ) );
112 qDebug(
"%s(%d): (%s), %s: %d", file +
sPrefixLength, line,
function, var.toLocal8Bit().constData(), val );
114 qDebug(
"%s: %d: (%s), %s: %d", file +
sPrefixLength, line,
function, var.toLocal8Bit().constData(), val );
116 logMessageToFile( QString(
"%s: %d: (%s), %s: %d" ).arg( file +
sPrefixLength ).arg( line ).arg(
function ).arg( var.toLocal8Bit().constData() ).arg( val ) );
121 void QgsLogger::debug(
const QString& var,
double val,
int debuglevel,
const char*
file,
const char*
function,
int line )
126 if ( !file || strncmp( dfile, file, strlen( dfile ) ) != 0 )
133 if ( dlevel >= debuglevel && debuglevel > 0 )
137 qDebug(
"%s: %f", var.toLocal8Bit().constData(), val );
138 logMessageToFile( QString(
"%s: %f" ).arg( var.toLocal8Bit().constData() ).arg( val ) );
140 else if ( !
function )
142 qDebug(
"%s: %s: %f", file +
sPrefixLength, var.toLocal8Bit().constData(), val );
145 else if ( line == -1 )
147 qDebug(
"%s: (%s): %s: %f", file +
sPrefixLength,
function, var.toLocal8Bit().constData(), val );
148 logMessageToFile( QString(
"%s: (%s): %s: %f" ).arg( file +
sPrefixLength ).arg(
function ).arg( var.toLocal8Bit().constData() ).arg( val ) );
153 qDebug(
"%s(%d): (%s), %s: %f", file +
sPrefixLength, line,
function, var.toLocal8Bit().constData(), val );
155 qDebug(
"%s: %d: (%s), %s: %f", file +
sPrefixLength, line,
function, var.toLocal8Bit().constData(), val );
157 logMessageToFile( QString(
"%s: %d: (%s), %s: %f" ).arg( file +
sPrefixLength ).arg( line ).arg(
function ).arg( var.toLocal8Bit().constData() ).arg( val ) );
165 qWarning(
"%s", msg.toLocal8Bit().constData() );
171 qCritical(
"%s", msg.toLocal8Bit().constData() );
177 qFatal(
"%s", msg.toLocal8Bit().constData() );
192 const char* dlevel = getenv(
"QGIS_DEBUG" );
193 if ( dlevel == NULL )
218 const QString
logFile = getenv(
"QGIS_LOG_FILE" );
228 file.open( QIODevice::Append );
229 file.write( theMessage.toStdString().c_str() );
238 const char* dfile = getenv(
"QGIS_DEBUG_FILE" );