iOS: log messages

So far we only wrote messages to subsurface.log on Android (since we couldn't
figure out how to make that file user accessible on iOS). Now that that's
fixed, we also need to actually write to the file in the first place.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2018-04-13 16:53:51 -07:00
parent 27b921fb1d
commit 0df43252be
3 changed files with 10 additions and 5 deletions

View file

@ -373,7 +373,7 @@ void QMLManager::finishSetup()
QMLManager::~QMLManager()
{
#if defined(Q_OS_ANDROID)
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
if (appLogFileOpen)
appLogFile.close();
#endif
@ -1630,7 +1630,7 @@ void QMLManager::setBtEnabled(bool value)
m_btEnabled = value;
}
#if defined (Q_OS_ANDROID)
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
void writeToAppLogFile(QString logText)
{
@ -1649,7 +1649,9 @@ void QMLManager::writeToAppLogFile(QString logText)
appLogFile.flush();
}
}
#endif
#if defined(Q_OS_ANDROID)
//HACK to color the system bar on Android, use qtandroidextras and call the appropriate Java methods
//this code is based on code in the Kirigami example app for Android (under LGPL-2) Copyright 2017 Marco Martin

View file

@ -143,7 +143,7 @@ public:
Q_INVOKABLE void setStatusbarColor(QColor color);
void btHostModeChange(QBluetoothLocalDevice::HostMode state);
#if defined(Q_OS_ANDROID)
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
void writeToAppLogFile(QString logText);
#endif

View file

@ -5,11 +5,14 @@
#if !defined(Q_OS_ANDROID)
#define INFO(fmt, ...) fprintf(stderr, "INFO: " fmt "\n", ##__VA_ARGS__)
#else
extern void writeToAppLogFile(QString logText);
#include <android/log.h>
#define INFO(fmt, ...) __android_log_print(ANDROID_LOG_DEBUG, __FILE__, "INFO: " fmt "\n", ##__VA_ARGS__);
#endif
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
extern void writeToAppLogFile(QString logText);
#endif
void logMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
Q_UNUSED(context)
@ -43,7 +46,7 @@ void MessageHandlerModel::addLog(QtMsgType type, const QString& message)
m_data.append({message, type});
endInsertRows();
INFO("%s", qPrintable(message));
#if defined (Q_OS_ANDROID)
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
writeToAppLogFile(message);
#endif
}