diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2018-03-08 13:19:18 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2018-03-09 16:31:53 +0000 |
commit | 73b2dd49c2396ab6a2b8ee31385119ec41257920 (patch) | |
tree | 030ac6d829c55766b38e749f391b6e1c31adc893 /src/testlib/qtestlog.cpp | |
parent | bc008afb0e3724a89890e9bd68451b1903bc8e17 (diff) |
testlib: Feed test log messages to Apple Unified Logging
QtTestLib uses its own message handler for plain text logging, so it doesn't
go though the logic in qDefaultMessageHandler that dispatches logging to
alternate logging sinks.
Building on the approach of Android and Windows, we log to AUL from the
plain text logger. A future improvement in this area would be to make
QtTestLib make more use of the infrastructure in qlogging.cpp, but this
is a bigger task and requires a better overview of the requirements.
The AUL code has been isolated into a wrapper, to allow logging both
to AUl and to e.g. the QPlainTextLogger. This is needed so that we
short circuit the plain text logger in case AUL already has handled
printing to stderr.
Change-Id: Iee0c3902190bd081b7ffbaf77c41b3118ce7f6da
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/testlib/qtestlog.cpp')
-rw-r--r-- | src/testlib/qtestlog.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp index 4964c6538e..1c864db71a 100644 --- a/src/testlib/qtestlog.cpp +++ b/src/testlib/qtestlog.cpp @@ -51,6 +51,10 @@ #include <QtTest/private/qxctestlogger_p.h> #endif +#if defined(Q_OS_DARWIN) +#include <QtTest/private/qappletestlogger_p.h> +#endif + #include <QtCore/qatomic.h> #include <QtCore/qbytearray.h> #include <QtCore/QElapsedTimer> @@ -502,6 +506,15 @@ void QTestLog::addLogger(LogMode mode, const char *filename) break; #endif } + +#if defined(QT_USE_APPLE_UNIFIED_LOGGING) + // Logger that also feeds messages to AUL. It needs to wrap the existing + // logger, as it needs to be able to short circuit the existing logger + // in case AUL prints to stderr. + if (QAppleTestLogger::debugLoggingEnabled()) + logger = new QAppleTestLogger(logger); +#endif + QTEST_ASSERT(logger); QTest::TestLoggers::addLogger(logger); } |