mirror of
https://gitlab.com/eql/lqml.git
synced 2025-12-09 03:50:29 -08:00
example 'meshtastic': add debug log to android service
This commit is contained in:
parent
5960668162
commit
28875816c2
1 changed files with 19 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
|||
#include "qtandroidservice_ro.h"
|
||||
#include <android/log.h>
|
||||
|
||||
#if (QT_VERSION < 0x060000)
|
||||
#include <QAndroidService>
|
||||
|
|
@ -6,9 +7,27 @@
|
|||
#include <QtCore/private/qandroidextras_p.h>
|
||||
#endif
|
||||
|
||||
static void logMessageHandler(QtMsgType, const QMessageLogContext& context, const QString& msg) {
|
||||
// for logging 'qDebug()' output
|
||||
QString report(msg);
|
||||
if (context.file && !QString(context.file).isEmpty()) {
|
||||
report += " in file ";
|
||||
report += QString(context.file);
|
||||
report += " line ";
|
||||
report += QString::number(context.line);
|
||||
}
|
||||
if (context.function && !QString(context.function).isEmpty()) {
|
||||
report += " function ";
|
||||
report += QString(context.function);
|
||||
}
|
||||
__android_log_write(ANDROID_LOG_DEBUG, "[LQML]", report.toLocal8Bit().constData());
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
QAndroidService app(argc, argv);
|
||||
|
||||
qInstallMessageHandler(logMessageHandler);
|
||||
|
||||
QRemoteObjectHost srcNode(QUrl(QStringLiteral("local:replica")));
|
||||
QtAndroidService qtAndroidService;
|
||||
srcNode.enableRemoting(&qtAndroidService);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue