wasm: log using emscripten_log() by default

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ø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Morten Sørvig 2024-03-25 14:24:25 +01:00 committed by Morten Johan Sørvig
parent d570293bb8
commit 7ba4486e7e

View File

@ -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();