mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Make message handler write to console as well
This way we can see the debug output even if the app is hung or crashes. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
0ea6f13891
commit
2d8489158d
2 changed files with 11 additions and 0 deletions
|
@ -1,5 +1,14 @@
|
||||||
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
#include "messagehandlermodel.h"
|
#include "messagehandlermodel.h"
|
||||||
|
|
||||||
|
/* based on logging bits from libdivecomputer */
|
||||||
|
#ifndef __ANDROID__
|
||||||
|
#define INFO(fmt, ...) fprintf(stderr, "INFO: " fmt "\n", ##__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#include <android/log.h>
|
||||||
|
#define INFO(fmt, ...) __android_log_print(ANDROID_LOG_DEBUG, __FILE__, "INFO: " fmt "\n", ##__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
void logMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
void logMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||||
{
|
{
|
||||||
MessageHandlerModel::self()->addLog(type, msg);
|
MessageHandlerModel::self()->addLog(type, msg);
|
||||||
|
@ -30,6 +39,7 @@ void MessageHandlerModel::addLog(QtMsgType type, const QString& message)
|
||||||
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
||||||
m_data.append({message, type});
|
m_data.append({message, type});
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
INFO("%s", message.toUtf8().constData());
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant MessageHandlerModel::data(const QModelIndex& idx, int role) const
|
QVariant MessageHandlerModel::data(const QModelIndex& idx, int role) const
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
#ifndef MESSAGEHANDLERMODEL_H
|
#ifndef MESSAGEHANDLERMODEL_H
|
||||||
#define MESSAGEHANDLERMODEL_H
|
#define MESSAGEHANDLERMODEL_H
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue