7 #define LOGGING_ENABLED 29 LastError& setError(std::string& where, std::string& msg);
30 LastError& setError(
const char* where,
const char* msg, ...);
32 std::string getError();
33 std::string getErrorMsg();
43 #define LASTERROR(msg, ...) Base::LastError::Instance().setError(__FUNCTION__, msg, __VA_ARGS__) 44 #define CLEARLASTERROR() Base::LastError::Instance().setError("", "") 52 static int getIndent();
111 Stream(QIODevice* device) : ts(device), ref(1), type(QtDebugMsg),
space(
true), message_output(
false) {}
112 Stream(QString*
string) : ts(
string, QIODevice::WriteOnly), ref(1), type(QtDebugMsg),
space(
true), message_output(
false) {}
113 Stream(QtMsgType t) : ts(&buffer, QIODevice::WriteOnly), ref(1), type(t),
space(
true), message_output(
true) {}
123 #if QT_VERSION >= 0x050000 124 QMessageLogContext context;
129 inline LogClass(QIODevice* device) : stream(new Stream(device)) {}
130 inline LogClass(QString*
string) : stream(new Stream(string)) {}
138 if (stream->message_output && !stream->buffer.isEmpty())
143 if (mylevel ==
D_ALL)
155 if (mylevel ==
D_OFF)
158 QString msg = QString(buf2) + QString(stream->buffer);
159 QMessageLogContext context;
160 qt_message_output(stream->type, context, msg);
168 stream->space =
true;
174 stream->space =
false;
186 stream->ts <<
"\'" << t <<
"\'";
191 stream->ts << (bool(t) ?
"true" :
"false");
231 stream->ts << QString::number(t);
236 stream->ts << QString::number(t);
251 stream->ts << qPrintable(t);
262 stream->ts << t.latin1();
290 #ifdef LOGGING_ENABLED 291 void LogV(
LOGLEVEL level,
const QString& s, va_list ap);
297 #define LOGCOMMAND_DEBUG(x) Base::ScopedLogger _____scopedLogger(Base::D_DEBUG, x); 298 #define LOGCOMMAND_INFO(x) Base::ScopedLogger _____scopedLogger(Base::D_INFO, x); 299 #define LOGCOMMAND(x) Base::ScopedLogger _____scopedLogger(Base::D_WARN, x); 300 #define LOGCOMMAND_WARN(x) Base::ScopedLogger _____scopedLogger(Base::D_WARN, x); 301 #define cUserDebug(...) \ 302 if (Base::Settings::getInstance()->getDebugUser()) \ 304 cWarn( __VA_ARGS__); \ 306 #define LOGVAR(var) cDebug() << QString("%1 = %2").arg(#var).arg(var); 318 void setCallBack( std::function<
bool(std::string)> f ) { mCallback = f; }
319 bool callCallBack(std::string s) {
if(mCallback)
return mCallback(s);
return false; }
322 std::function<bool(std::string)> mCallback;
333 static Logger& instance();
334 static void log(
const char* format, ... );
335 static void log( QString s );
339 Logger(QString path) : logFilePath(path) {}
353 #define myLog(a) Logger::instance().writeToLog(a); 354 #define myLogAtFinish(a) ScopedLog(a); 361 #ifdef LOGGING_ENABLED 363 #define cAssert(condition, message) \ 365 if (! (condition)) { \ 366 std::stringstream ss;\ 367 ss << "Assertion: `" #condition << "` --> '" << message << "' failed in \n" << __FILE__ << ":" << __LINE__ << "\n"; \ 368 std::cerr << ss.str();\ 369 if( Base::AssertSingleton::getInstance().callCallBack(ss.str())) exit(1);\ 395 LX_CORE_EXPORT
void noDebug(
const char*, ...);
396 LX_CORE_EXPORT
void noDebug(
const QString &);
398 #define cAssert(condition, message) do { } while (false) 399 #define cDebug while(false) noDebug 400 #define cInfo while(false) noDebug 401 #define cError while(false) noDebug 402 #define cWarn while(false) noDebug LX_BASE_EXPORT LOGLEVEL getLogLevel()
NoDebugClass & nospace()
Definition: Log.h:96
LogClass & operator<<(unsigned int t)
Definition: Log.h:214
LogClass & operator<<(char t)
Definition: Log.h:194
LX_BASE_EXPORT Base::LogClass cInfo()
LX_BASE_EXPORT Base::LogClass cDebug()
QString m_msg
Definition: Log.h:350
~LogClass()
Definition: Log.h:134
static bool is_activated
Definition: Log.h:287
LogClass & operator<<(const QStringRef &t)
Definition: Log.h:259
LX_BASE_EXPORT Base::LogClass cError()
LogClass & operator<<(const QByteArray &t)
Definition: Log.h:265
LogClass & operator<<(signed int t)
Definition: Log.h:209
LogClass(LOGLEVEL level, QtMsgType t)
Definition: Log.h:131
NoDebugClass & operator<<(const T &)
Definition: Log.h:103
static Logger & instance()
LogClass & operator<<(quint64 t)
Definition: Log.h:234
static void log(const char *format,...)
NoDebugClass & operator<<(QTextStreamFunction)
Definition: Log.h:93
LogClass & operator=(const QDebug &other)
virtual LogBaseClass & nospace()=0
LogClass & nospace()
Definition: Log.h:172
void LogV(LOGLEVEL level, const QString &s, va_list ap)
LogClass & operator<<(bool t)
Definition: Log.h:189
LogClass & operator<<(signed short t)
Definition: Log.h:199
LogClass & operator<<(float t)
Definition: Log.h:239
LogClass & operator<<(QTextStreamFunction f)
Definition: Log.h:275
~ScopedLog()
Definition: Log.h:349
LX_BASE_EXPORT void cDebuggerBreak(char *message)
LX_BASE_EXPORT LogClass Log(Base::LOGLEVEL level)
LogClass & space()
Definition: Log.h:166
ScopedLoggerP * _piml
Definition: Log.h:54
NoDebugClass & space()
Definition: Log.h:95
LogClass & operator<<(QTextStreamManipulator m)
Definition: Log.h:281
NoDebugClass & maybeQuote(const char='"')
Definition: Log.h:100
bool callCallBack(std::string s)
Definition: Log.h:319
static AssertSingleton & getInstance()
Definition: Log.h:311
LogClass & operator<<(signed long t)
Definition: Log.h:219
NoDebugClass & maybeSpace()
Definition: Log.h:97
LogClass & operator<<(unsigned long t)
Definition: Log.h:224
LogClass & operator<<(QChar t)
Definition: Log.h:184
LogClass & operator<<(const QLatin1String &t)
Definition: Log.h:260
LogClass(const LogClass &o)
Definition: Log.h:132
LogClass & operator<<(const void *t)
Definition: Log.h:270
LogClass & maybeSpace()
Definition: Log.h:177
LogClass & operator<<(unsigned short t)
Definition: Log.h:204
NoDebugClass & operator<<(QTextStreamManipulator)
Definition: Log.h:94
LOGLEVEL
Definition: Log.h:11
virtual LogBaseClass & maybeSpace()=0
void setCallBack(std::function< bool(std::string)> f)
Definition: Log.h:318
NoDebugClass & noquote()
Definition: Log.h:99
LogClass & operator<<(qint64 t)
Definition: Log.h:229
LogClass & operator<<(double t)
Definition: Log.h:244
LX_BASE_EXPORT void setLogLevel(LOGLEVEL)
Definition: AbstractXMLReader.h:5
virtual LogBaseClass & space()=0
NoDebugClass & quote()
Definition: Log.h:98
LogClass & operator<<(const char *t)
Definition: Log.h:249
LX_BASE_EXPORT Base::LogClass cWarn()
ScopedLog(QString a)
Definition: Log.h:348
virtual LogBaseClass & operator<<(QChar t)=0
LogClass(QIODevice *device)
Definition: Log.h:129
LogClass & operator<<(const QString &t)
Definition: Log.h:254
LogClass(QString *string)
Definition: Log.h:130