mirror of
https://github.com/KDE/kasts.git
synced 2024-12-23 07:00:20 +01:00
Add basic logging capabilities on android.
This implements debug logging which can be checked through logcat.
This commit is contained in:
parent
60432619f1
commit
4d6d8ae940
@ -81,7 +81,8 @@ ecm_qt_declare_logging_category(SRCS_base
|
||||
)
|
||||
|
||||
if(ANDROID)
|
||||
set (SRCS ${SRCS_base})
|
||||
set (SRCS ${SRCS_base}
|
||||
androidlogging.h)
|
||||
else()
|
||||
set (SRCS ${SRCS_base}
|
||||
mpris2/mediaplayer2.cpp
|
||||
@ -104,6 +105,7 @@ if(ANDROID)
|
||||
KF5::Kirigami2
|
||||
Qt::Svg
|
||||
OpenSSL::SSL
|
||||
log
|
||||
)
|
||||
|
||||
kirigami_package_breeze_icons(ICONS
|
||||
|
36
src/androidlogging.h
Normal file
36
src/androidlogging.h
Normal file
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2021 Bart De Vries <bart@mogwai.be>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <android/log.h>
|
||||
|
||||
const char *applicationName="org.kde.kasts";
|
||||
void myMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg)
|
||||
{
|
||||
QByteArray localMsg = msg.toLocal8Bit();
|
||||
// const char *file = context.file ? context.file : "";
|
||||
// const char *function = context.function ? context.function : "";
|
||||
switch (type) {
|
||||
case QtDebugMsg:
|
||||
__android_log_write(ANDROID_LOG_DEBUG,applicationName,localMsg.constData());
|
||||
break;
|
||||
case QtInfoMsg:
|
||||
__android_log_write(ANDROID_LOG_INFO,applicationName,localMsg.constData());
|
||||
break;
|
||||
case QtWarningMsg:
|
||||
__android_log_write(ANDROID_LOG_WARN,applicationName,localMsg.constData());
|
||||
break;
|
||||
case QtCriticalMsg:
|
||||
__android_log_write(ANDROID_LOG_ERROR,applicationName,localMsg.constData());
|
||||
break;
|
||||
case QtFatalMsg:
|
||||
default:
|
||||
__android_log_write(ANDROID_LOG_FATAL,applicationName,localMsg.constData());
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <QCommandLineOption>
|
||||
#include <QCommandLineParser>
|
||||
#include <QIcon>
|
||||
#include <QLoggingCategory>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QQmlContext>
|
||||
#include <QQuickStyle>
|
||||
@ -26,6 +27,9 @@
|
||||
#include <KLocalizedContext>
|
||||
#include <KLocalizedString>
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
#include "androidlogging.h"
|
||||
#endif
|
||||
#include "audiomanager.h"
|
||||
#include "database.h"
|
||||
#include "datamanager.h"
|
||||
@ -48,6 +52,8 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
#ifdef Q_OS_ANDROID
|
||||
QGuiApplication app(argc, argv);
|
||||
qInstallMessageHandler(myMessageHandler);
|
||||
QLoggingCategory::setFilterRules(QStringLiteral("org.kde.*=true"));
|
||||
QQuickStyle::setStyle(QStringLiteral("Material"));
|
||||
#else
|
||||
QApplication app(argc, argv);
|
||||
|
Loading…
Reference in New Issue
Block a user