#include <QtCore/QString>
#include <QtCore/QVariant>
Go to the source code of this file.
Namespaces | |
namespace | Log4Qt |
Classes | |
class | Log4Qt::LogError |
The class LogError represents an error. More... | |
Defines | |
#define | LOG4QT_ERROR(message, code, context) LogError(message, code, #code, context) |
#define | LOG4QT_QCLASS_ERROR(message, code) LogError(message, code, #code, this->metaObject()->className()) |
Functions | |
Q_DECLARE_TYPEINFO (Log4Qt::LogError, Q_MOVABLE_TYPE) |
#define LOG4QT_ERROR | ( | message, | |||
code, | |||||
context | ) | LogError(message, code, #code, context) |
Creates an LogError object with the error message message, the error code code and the context context. The symbol of the error is set to code as string value.
The following example logs an error, if a character is not a digit.
if (!c.isDigit()) { Error e = LOG4QT_ERROR(QT_TR_NOOP("Found character '%1' where digit was expected."), LAYOUT_EXPECTED_DIGIT_ERROR, "Log4Qt::PatternFormatter"); e << QString(c); logger()->error(e); }
#define LOG4QT_QCLASS_ERROR | ( | message, | |||
code | ) | LogError(message, code, #code, this->metaObject()->className()) |
Creates an LogError object with the error message message and the error code code. The symbol of the error is set to code as string value. The context is set to the class name of the current object. The current objects class must be derived from QObject.
The following example handles an error while opening a file.
if (!mpFile->open(mode)) { LogError e = LOG4QT_QCLASS_ERROR(QT_TR_NOOP("Unable to open file '%1' for appender '%2'"), APPENDER_OPENING_FILE_ERROR); e << mFileName << name(); e.addCausingError(LogError(mpFile->errorString(), mpFile->error())); logger()->error(e); return; }
Q_DECLARE_TYPEINFO | ( | Log4Qt::LogError | , | |
Q_MOVABLE_TYPE | ||||
) |