QGIS API Documentation
2.2.0-Valmiera
|
QgsLogger is a class to print debug/warning/error messages to the console. More...
#include <qgslogger.h>
Static Public Member Functions | |
static void | debug (const QString &msg, int debuglevel=1, const char *file=NULL, const char *function=NULL, int line=-1) |
Goes to qDebug. | |
static void | debug (const QString &var, int val, int debuglevel=1, const char *file=NULL, const char *function=NULL, int line=-1) |
Similar to the previous method, but prints a variable int-value pair. | |
static void | debug (const QString &var, double val, int debuglevel=1, const char *file=NULL, const char *function=NULL, int line=-1) |
Similar to the previous method, but prints a variable double-value pair. | |
template<typename T > | |
static void | debug (const QString &var, T val, const char *file=0, const char *function=0, int line=-1, int debuglevel=1) |
Prints out a variable/value pair for types with overloaded operator<<. | |
static void | warning (const QString &msg) |
Goes to qWarning. | |
static void | critical (const QString &msg) |
Goes to qCritical. | |
static void | fatal (const QString &msg) |
Goes to qFatal. | |
static int | debugLevel () |
Reads the environment variable QGIS_DEBUG and converts it to int. | |
static void | logMessageToFile (QString theMessage) |
Logs the message passed in to the logfile defined in QGIS_LOG_FILE if any. |
Static Private Member Functions | |
static const QString | logFile () |
Reads the environment variable QGIS_LOG_FILE. | |
static const char * | debugFile () |
Reads the environment variable QGIS_DEBUG_FILE. |
Static Private Attributes | |
static int | sDebugLevel = -999 |
current debug level | |
static int | sPrefixLength = -1 |
QgsLogger is a class to print debug/warning/error messages to the console.
The advantage of this class over iostream & co. is that the output can be controlled with environment variables: QGIS_DEBUG is an int describing what debug messages are written to the console. If the debug level of a message is <= QGIS_DEBUG, the message is written to the console. It the variable QGIS_DEBUG is not defined, it defaults to 1 for debug mode and to 0 for release mode QGIS_DEBUG_FILE may contain a file name. Only the messages from this file are printed (provided they have the right debuglevel). If QGIS_DEBUG_FILE is not set, messages from all files are printed
QGIS_LOG_FILE may contain a file name. If set, all messages will be appended to this file rather than to stdout.
Definition at line 56 of file qgslogger.h.
|
static |
|
static |
Goes to qDebug.
msg | the message to be printed |
debuglevel | |
file | file name where the message comes from |
function | function where the message comes from |
line | place in file where the message comes from |
Definition at line 33 of file qgslogger.cpp.
References debugFile(), debugLevel(), logFile(), logMessageToFile(), and sPrefixLength.
Referenced by QgsScopeLogger::QgsScopeLogger(), and QgsScopeLogger::~QgsScopeLogger().
|
static |
Similar to the previous method, but prints a variable int-value pair.
Definition at line 80 of file qgslogger.cpp.
References debugFile(), debugLevel(), logMessageToFile(), and sPrefixLength.
|
static |
Similar to the previous method, but prints a variable double-value pair.
Definition at line 121 of file qgslogger.cpp.
References debugFile(), debugLevel(), logMessageToFile(), and sPrefixLength.
|
inlinestatic |
Prints out a variable/value pair for types with overloaded operator<<.
Definition at line 77 of file qgslogger.h.
References file.
|
staticprivate |
Reads the environment variable QGIS_DEBUG_FILE.
Returns NULL if the variable is not set. If set, only messages from this source file will be sent to logs.
Definition at line 238 of file qgslogger.cpp.
Referenced by debug().
|
static |
Reads the environment variable QGIS_DEBUG and converts it to int.
If QGIS_DEBUG is not set, the function returns 1 if QGISDEBUG is defined and 0 if not
Definition at line 180 of file qgslogger.cpp.
References sDebugLevel, and sPrefixLength.
Referenced by debug().
|
static |
|
staticprivate |
Reads the environment variable QGIS_LOG_FILE.
Returns NULL if the variable is not set, otherwise returns a file name for writing log messages to.
Definition at line 218 of file qgslogger.cpp.
Referenced by debug(), and logMessageToFile().
|
static |
Logs the message passed in to the logfile defined in QGIS_LOG_FILE if any.
Definition at line 224 of file qgslogger.cpp.
References file, and logFile().
Referenced by critical(), debug(), fatal(), and warning().
|
static |
Goes to qWarning.
Definition at line 162 of file qgslogger.cpp.
References logMessageToFile().
Referenced by QgsRelation::createFromXML(), QgsVectorFileWriter::exportFeaturesSymbolLevels(), QgsMapLayer::loadNamedStyle(), QgsProviderRegistry::provider(), QgsProject::read(), QgsCoordinateReferenceSystem::setupESRIWktFix(), and QgsVectorFileWriter::writeAsVectorFormat().
|
staticprivate |
|
staticprivate |
Definition at line 132 of file qgslogger.h.
Referenced by debug(), and debugLevel().