improved debug messages in XBus

This commit is contained in:
Mathew Sutcliffe
2014-07-14 23:26:47 +01:00
parent c2ca71c2a2
commit cd82c7f55d

View File

@@ -31,23 +31,23 @@ class QXPlaneMessageHandler
static void handler(QtMsgType type, const QMessageLogContext &context, const QString &msg) static void handler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{ {
QByteArray localMsg = msg.toLocal8Bit(); QByteArray localMsg = msg.toLocal8Bit();
char *buffer = new char[64 + localMsg.size() + std::strlen(context.file) + std::strlen(context.function)]; char *buffer = new char[64 + localMsg.size() + std::strlen(context.file)];
switch (type) { switch (type) {
case QtDebugMsg: case QtDebugMsg:
std::sprintf(buffer, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); std::sprintf(buffer, "%s:%u: Debug: %s\n", context.file, context.line, localMsg.constData());
XPLMDebugString(buffer); XPLMDebugString(buffer);
break; break;
case QtWarningMsg: case QtWarningMsg:
std::sprintf(buffer, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); std::sprintf(buffer, "%s:%u: Warning: %s\n", context.file, context.line, localMsg.constData());
XPLMDebugString(buffer); XPLMDebugString(buffer);
break; break;
default: default:
case QtCriticalMsg: case QtCriticalMsg:
std::sprintf(buffer, "Error: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); std::sprintf(buffer, "%s:%u: Error: %s\n", context.file, context.line, localMsg.constData());
XPLMDebugString(buffer); XPLMDebugString(buffer);
break; break;
case QtFatalMsg: case QtFatalMsg:
std::sprintf(buffer, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); std::sprintf(buffer, "%s:%u: Fatal: %s\n", context.file, context.line, localMsg.constData());
XPLMDebugString(buffer); XPLMDebugString(buffer);
std::abort(); std::abort();
} }