summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/global/qlogging.cpp2
-rw-r--r--src/testlib/qplaintestlogger.cpp10
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