diff options
author | Kai Koehne <kai.koehne@digia.com> | 2014-01-07 14:43:22 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-13 09:44:40 +0100 |
commit | 7fab8eb56b9309734d1b34d3d935d6a4cf14ce6e (patch) | |
tree | 0f37e7764362e4f3c91df03fd1b212f1e89a8ee7 /src | |
parent | e1330ecfdccf75c3c3f93734e7950199918e6ad7 (diff) |
Windows: Do not print test output to both stdout and system debug log
Avoid piping the test output to both the Windows system debugger, and
stdout. This fixes duplicate output in Qt Creator, which displays messages
from both sources.
[ChangeLog][QtTestLib] The (default) plain text logger on Windows now
logs to either the system debug log (in case no console is open), or
stdout, not both.
Task-number: QTBUG-34630
Change-Id: I35fe9f4a50cc660d79fad7dffa6d19659b2102ae
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/global/qlogging.cpp | 2 | ||||
-rw-r--r-- | src/testlib/qplaintestlogger.cpp | 10 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index cc20891c76..5b7a674ddb 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -102,7 +102,7 @@ static inline bool hasStdErr() } # endif // !Q_OS_WINCE && !Q_OS_WINRT -bool qWinLogToStderr() +Q_CORE_EXPORT bool qWinLogToStderr() { # if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) static const bool result = hasStdErr(); diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp index 77be0e423e..3f65dc0a6e 100644 --- a/src/testlib/qplaintestlogger.cpp +++ b/src/testlib/qplaintestlogger.cpp @@ -197,6 +197,10 @@ namespace QTest { } } +#if defined(Q_OS_WIN) +Q_CORE_EXPORT bool qWinLogToStderr(); // defined in qlogging.cpp +#endif + void QPlainTestLogger::outputMessage(const char *str) { #if defined(Q_OS_WINCE) @@ -209,7 +213,11 @@ void QPlainTestLogger::outputMessage(const char *str) } while (!strUtf16.isEmpty()); if (stream != stdout) #elif defined(Q_OS_WIN) - OutputDebugStringA(str); + // log to system log only if output is not redirected, and no console is attached + if (!qWinLogToStderr() && stream == stdout) { + OutputDebugStringA(str); + return; + } #elif defined(Q_OS_ANDROID) __android_log_write(ANDROID_LOG_INFO, "QTestLib", str); #endif |