diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2017-06-05 19:56:52 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-06-11 13:55:41 -0700 |
commit | 2d8489158da2e049a89734d2a95434ffec005fee (patch) | |
tree | cc1db980c0465bce268a8364e6c1f8ff052f3782 | |
parent | 0ea6f13891cff45d1da7cb23a5e07a2080827b78 (diff) | |
download | subsurface-2d8489158da2e049a89734d2a95434ffec005fee.tar.gz |
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>
-rw-r--r-- | qt-models/messagehandlermodel.cpp | 10 | ||||
-rw-r--r-- | qt-models/messagehandlermodel.h | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/qt-models/messagehandlermodel.cpp b/qt-models/messagehandlermodel.cpp index daedad897..85c8d6500 100644 --- a/qt-models/messagehandlermodel.cpp +++ b/qt-models/messagehandlermodel.cpp @@ -1,5 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0 #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) { MessageHandlerModel::self()->addLog(type, msg); @@ -30,6 +39,7 @@ void MessageHandlerModel::addLog(QtMsgType type, const QString& message) beginInsertRows(QModelIndex(), rowCount(), rowCount()); m_data.append({message, type}); endInsertRows(); + INFO("%s", message.toUtf8().constData()); } QVariant MessageHandlerModel::data(const QModelIndex& idx, int role) const diff --git a/qt-models/messagehandlermodel.h b/qt-models/messagehandlermodel.h index 7fb5c6515..b59a4eca3 100644 --- a/qt-models/messagehandlermodel.h +++ b/qt-models/messagehandlermodel.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 #ifndef MESSAGEHANDLERMODEL_H #define MESSAGEHANDLERMODEL_H |