aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorAurindam Jana <aurindam.jana@nokia.com>2012-02-21 14:56:24 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-21 15:39:57 +0100
commita73ad904c9a4ad188604de6c64a6c91cd514dc1b (patch)
treeeefdd058364d35fd337d93038a4661b4d5431d6b /src/declarative
parent784d867d2b79fcfdbf039456fcfe0692652fec52 (diff)
DebugMessageService: Also pass Debug Context Info
Use QMessageHandler which provides context information such as line, file and function for the debug output. Change-Id: I475faf4a1363d8419dec910b8a23cc44666c1908 Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/debugger/qdebugmessageservice.cpp23
-rw-r--r--src/declarative/debugger/qdebugmessageservice_p.h5
2 files changed, 18 insertions, 10 deletions
diff --git a/src/declarative/debugger/qdebugmessageservice.cpp b/src/declarative/debugger/qdebugmessageservice.cpp
index e7c4901a48..4a17da94fa 100644
--- a/src/declarative/debugger/qdebugmessageservice.cpp
+++ b/src/declarative/debugger/qdebugmessageservice.cpp
@@ -46,9 +46,10 @@ QT_BEGIN_NAMESPACE
Q_GLOBAL_STATIC(QDebugMessageService, declarativeDebugMessageService)
-void DebugMessageHandler(QtMsgType type, const char *buf)
+void DebugMessageHandler(QtMsgType type, const QMessageLogContext &ctxt,
+ const char *buf)
{
- QDebugMessageService::instance()->sendDebugMessage(type, buf);
+ QDebugMessageService::instance()->sendDebugMessage(type, ctxt, buf);
}
class QDebugMessageServicePrivate : public QDeclarativeDebugServicePrivate
@@ -60,7 +61,7 @@ public:
{
}
- QtMsgHandler oldMsgHandler;
+ QMessageHandler oldMsgHandler;
QDeclarativeDebugService::State prevState;
};
@@ -72,7 +73,7 @@ QDebugMessageService::QDebugMessageService(QObject *parent) :
registerService();
if (state() == Enabled) {
- d->oldMsgHandler = qInstallMsgHandler(DebugMessageHandler);
+ d->oldMsgHandler = qInstallMessageHandler(DebugMessageHandler);
d->prevState = Enabled;
}
}
@@ -82,7 +83,9 @@ QDebugMessageService *QDebugMessageService::instance()
return declarativeDebugMessageService();
}
-void QDebugMessageService::sendDebugMessage(QtMsgType type, const char *buf)
+void QDebugMessageService::sendDebugMessage(QtMsgType type,
+ const QMessageLogContext &ctxt,
+ const char *buf)
{
Q_D(QDebugMessageService);
@@ -92,10 +95,12 @@ void QDebugMessageService::sendDebugMessage(QtMsgType type, const char *buf)
QByteArray message;
QDataStream ws(&message, QIODevice::WriteOnly);
ws << QByteArray("MESSAGE") << type << QString::fromLocal8Bit(buf).toUtf8();
+ ws << ctxt.version << QString::fromLatin1(ctxt.file).toUtf8();
+ ws << ctxt.line << QString::fromLatin1(ctxt.function).toUtf8();
sendMessage(message);
if (d->oldMsgHandler)
- (*d->oldMsgHandler)(type, buf);
+ (*d->oldMsgHandler)(type, ctxt, buf);
}
void QDebugMessageService::stateChanged(State state)
@@ -103,13 +108,13 @@ void QDebugMessageService::stateChanged(State state)
Q_D(QDebugMessageService);
if (state != Enabled && d->prevState == Enabled) {
- QtMsgHandler handler = qInstallMsgHandler(d->oldMsgHandler);
+ QMessageHandler handler = qInstallMessageHandler(d->oldMsgHandler);
// has our handler been overwritten in between?
if (handler != DebugMessageHandler)
- qInstallMsgHandler(handler);
+ qInstallMessageHandler(handler);
} else if (state == Enabled && d->prevState != Enabled) {
- d->oldMsgHandler = qInstallMsgHandler(DebugMessageHandler);
+ d->oldMsgHandler = qInstallMessageHandler(DebugMessageHandler);
}
diff --git a/src/declarative/debugger/qdebugmessageservice_p.h b/src/declarative/debugger/qdebugmessageservice_p.h
index bf0e17c2fe..b907341541 100644
--- a/src/declarative/debugger/qdebugmessageservice_p.h
+++ b/src/declarative/debugger/qdebugmessageservice_p.h
@@ -55,6 +55,8 @@
#include "qdeclarativedebugservice_p.h"
+#include <QtCore/qlogging.h>
+
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -71,7 +73,8 @@ public:
static QDebugMessageService *instance();
- void sendDebugMessage(QtMsgType type, const char *buf);
+ void sendDebugMessage(QtMsgType type, const QMessageLogContext &ctxt,
+ const char *buf);
protected:
void stateChanged(State);