From 7ba4486e7e627eb19b90059e52052693b164d6ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Mon, 25 Mar 2024 14:24:25 +0100 Subject: [PATCH] wasm: log using emscripten_log() by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Log using emscripten_log by default, unless QT_FORCE_STDERR_LOGGING has been set. It is now possible to log at different levels: qDebug() -> Info qWarning() -> Warning qCritical() -> Error #ifdef out functions which are now no longer in use on Q_OS_WASM Change-Id: I0485e5c070069998a8dfc6759c02bc3b7d6a8a4b Reviewed-by: Tor Arne Vestbø Reviewed-by: Qt CI Bot --- src/corelib/global/qlogging.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 9ec936af228..71579ca08ad 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -226,6 +226,8 @@ static bool systemHasStderr() return true; } +#ifndef Q_OS_WASM + /*! Returns true if writing to \c stderr will end up in a console/terminal visible to the user. @@ -310,6 +312,8 @@ bool shouldLogToStderr() using namespace QtPrivate; +#endif // ifndef Q_OS_WASM + /*! \class QMessageLogContext \inmodule QtCore @@ -1868,8 +1872,9 @@ static bool wasm_default_message_handler(QtMsgType type, const QMessageLogContext &, const QString &formattedMessage) { - if (shouldLogToStderr()) - return false; // Leave logging up to stderr handler + static bool forceStderrLogging = qEnvironmentVariableIntValue("QT_FORCE_STDERR_LOGGING"); + if (forceStderrLogging) + return false; int emOutputFlags = EM_LOG_CONSOLE; QByteArray localMsg = formattedMessage.toLocal8Bit();