summaryrefslogtreecommitdiffstats
path: root/src/corelib/global
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/global')
-rw-r--r--src/corelib/global/qlogging.cpp24
-rw-r--r--src/corelib/global/qsystemdetection.h4
2 files changed, 28 insertions, 0 deletions
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index 7204efc752..6a127e1786 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -57,6 +57,10 @@
#include <slog2.h>
#endif
+#ifdef Q_OS_ANDROID
+#include <android/log.h>
+#endif
+
#include <stdio.h>
QT_BEGIN_NAMESPACE
@@ -835,6 +839,24 @@ Q_CORE_EXPORT QtMsgHandler qInstallMsgHandler(QtMsgHandler);
static QtMsgHandler msgHandler = 0; // pointer to debug handler (without context)
static QtMessageHandler messageHandler = 0; // pointer to debug handler (with context)
+#ifdef Q_OS_ANDROID
+static void android_default_message_handler(QtMsgType type,
+ const QMessageLogContext &context,
+ const QString &message)
+{
+ android_LogPriority priority;
+ switch (type) {
+ case QtDebugMsg: priority = ANDROID_LOG_DEBUG; break;
+ case QtWarningMsg: priority = ANDROID_LOG_WARN; break;
+ case QtCriticalMsg: priority = ANDROID_LOG_ERROR; break;
+ case QtFatalMsg: priority = ANDROID_LOG_FATAL; break;
+ };
+
+ __android_log_print(priority, "Qt", "%s:%d (%s): %s", qPrintable(context.file), context.line,
+ qPrintable(context.function), qPrintable(message));
+}
+#endif //Q_OS_ANDROID
+
/*!
\internal
*/
@@ -855,6 +877,8 @@ static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &con
#if defined(QT_USE_SLOG2)
slog2_default_handler(type, logMessage.toLocal8Bit().constData());
+#elif defined(Q_OS_ANDROID)
+ android_default_message_handler(type, context, logMessage);
#else
fprintf(stderr, "%s", logMessage.toLocal8Bit().constData());
fflush(stderr);
diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h
index 6062dc7b7b..0caac3d797 100644
--- a/src/corelib/global/qsystemdetection.h
+++ b/src/corelib/global/qsystemdetection.h
@@ -80,6 +80,7 @@
LYNX - LynxOS
BSD4 - Any BSD 4.4 system
UNIX - Any UNIX BSD/SYSV system
+ ANDROID - Android platform
*/
#if defined(__APPLE__) && (defined(__GNUC__) || defined(__xlC__) || defined(__xlc__))
@@ -90,6 +91,9 @@
# else
# define Q_OS_DARWIN32
# endif
+#elif defined(ANDROID)
+# define Q_OS_ANDROID
+# define Q_OS_LINUX
#elif defined(__CYGWIN__)
# define Q_OS_CYGWIN
#elif !defined(SAG_COM) && (defined(WIN64) || defined(_WIN64) || defined(__WIN64__))