-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathqDebug2Logcat.cpp
More file actions
37 lines (34 loc) · 861 Bytes
/
qDebug2Logcat.cpp
File metadata and controls
37 lines (34 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#if defined(ANDROID)
#include "qDebug2Logcat.h"
#include <android/log.h>
#include <QDebug>
#include <QByteArray>
static const char *g_TAG = 0;
static void messageOutput2Logcat(QtMsgType type,
const QMessageLogContext &context,
const QString &msg)
{
int prio = ANDROID_LOG_VERBOSE;
QByteArray localMsg = msg.toLocal8Bit();
switch (type) {
case QtDebugMsg:
prio = ANDROID_LOG_DEBUG;
break;
case QtWarningMsg:
prio = ANDROID_LOG_WARN;
break;
case QtCriticalMsg:
prio = ANDROID_LOG_INFO;
break;
case QtFatalMsg:
prio = ANDROID_LOG_FATAL;
abort();
}
__android_log_write(prio, g_TAG, localMsg.data());
}
void installLogcatMessageHandler(const char *TAG)
{
g_TAG = (TAG == 0 ? "QDebug" : TAG);
qInstallMessageHandler(messageOutput2Logcat);
}
#endif