summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qcoreapplication_win.cpp
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@nokia.com>2012-02-03 09:35:22 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-09 18:11:21 +0100
commitbe98fa32c7d56ea91359b647a329356fa44eca04 (patch)
tree7d3941bcfe07aebb95e74e7344c774f36eaccf17 /src/corelib/kernel/qcoreapplication_win.cpp
parente7e87993042ac9a4fd899da5ea0340322b47d9ff (diff)
Allow customization of qDebug output at runtime
Check the QT_OUTPUT_PATTERN environment variable in the default message handler to customize the output of messages. Following place holders are right now supported: %{message}, %{type}, %{file}, %{line}, %{function} The original cleanupFuncinfo was written by Thiago Macieira. Change-Id: I6ad25baaa0e6a1c9f886105d2a93ef3310e512a9 Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: David Faure <faure@kde.org>
Diffstat (limited to 'src/corelib/kernel/qcoreapplication_win.cpp')
-rw-r--r--src/corelib/kernel/qcoreapplication_win.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/corelib/kernel/qcoreapplication_win.cpp b/src/corelib/kernel/qcoreapplication_win.cpp
index 9a45f28f16..c1f7c8ab25 100644
--- a/src/corelib/kernel/qcoreapplication_win.cpp
+++ b/src/corelib/kernel/qcoreapplication_win.cpp
@@ -140,30 +140,30 @@ public:
{ LeaveCriticalSection(&cs); }
};
-Q_CORE_EXPORT void qWinMsgHandler(QtMsgType t, const char* str)
-{
- Q_UNUSED(t);
- // OutputDebugString is not threadsafe.
+// defined in qlogging.cpp
+extern Q_CORE_EXPORT QByteArray qMessageFormatString(QtMsgType type,
+ const QMessageLogContext &context,
+ const char *str);
+Q_CORE_EXPORT void qWinMessageHandler(QtMsgType t, const QMessageLogContext &context, const char *str)
+{
// cannot use QMutex here, because qWarning()s in the QMutex
// implementation may cause this function to recurse
static QWinMsgHandlerCriticalSection staticCriticalSection;
- if (!str)
- str = "(null)";
+ QByteArray message = qMessageFormatString(t, context, str);
+ QString s(QString::fromLocal8Bit(message));
+ // OutputDebugString is not threadsafe.
staticCriticalSection.lock();
-
- QString s(QString::fromLocal8Bit(str));
- s += QLatin1Char('\n');
OutputDebugString((wchar_t*)s.utf16());
-
staticCriticalSection.unlock();
}
-Q_CORE_EXPORT void qWinMessageHandler(QtMsgType t, const QMessageLogContext &, const char* str)
+Q_CORE_EXPORT void qWinMsgHandler(QtMsgType t, const char *str)
{
- qWinMsgHandler(t, str);
+ QMessageLogContext emptyContext;
+ qWinMessageHandler(t, emptyContext, str);
}
/*****************************************************************************