From f9f4a9c232357c3967394e8f6a64f9aa36430a45 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 17 Apr 2020 13:02:25 -0700 Subject: debug output: ensure our debug output is captured on Android I would have bet money that Android used to send stderr to the logcat log, but apparently it doesn't (anymore?). So in order to be able to have a chance to debug weird cloud storage issues on Android, let's do some wholesale replacement of fprintf(stderr,...) with our own version of the INFO macro that we long ago borrowed from libdivecomputer (and rename it to ensure we don't have a conflict there). Signed-off-by: Dirk Hohndel --- qt-models/divelocationmodel.cpp | 2 +- qt-models/messagehandlermodel.cpp | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) (limited to 'qt-models') diff --git a/qt-models/divelocationmodel.cpp b/qt-models/divelocationmodel.cpp index 5fca153a4..26cf3353e 100644 --- a/qt-models/divelocationmodel.cpp +++ b/qt-models/divelocationmodel.cpp @@ -229,7 +229,7 @@ QStringList DiveSiteSortedModel::allSiteNames() const // (more precisely: the core has more sites than the model is aware of), // we might get an invalid index. if (idx < 0 || idx > dive_site_table.nr) { - fprintf(stderr, "DiveSiteSortedModel::allSiteNames(): invalid index"); + SSRF_INFO("DiveSiteSortedModel::allSiteNames(): invalid index"); continue; } locationNames << QString(dive_site_table.dive_sites[idx]->name); diff --git a/qt-models/messagehandlermodel.cpp b/qt-models/messagehandlermodel.cpp index 4952758d2..f0807cf80 100644 --- a/qt-models/messagehandlermodel.cpp +++ b/qt-models/messagehandlermodel.cpp @@ -1,13 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include "messagehandlermodel.h" - -/* based on logging bits from libdivecomputer */ -#if !defined(Q_OS_ANDROID) -#define INFO(fmt, ...) fprintf(stderr, "INFO: " fmt "\n", ##__VA_ARGS__) -#else -#include -#define INFO(fmt, ...) __android_log_print(ANDROID_LOG_DEBUG, "Subsurface", "INFO: " fmt "\n", ##__VA_ARGS__); -#endif +#include "core/qthelper.h" #if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) extern void writeToAppLogFile(QString logText); @@ -49,7 +42,7 @@ void MessageHandlerModel::addLog(QtMsgType type, const QString& message) beginInsertRows(QModelIndex(), rowCount(), rowCount()); m_data.append({message, type}); endInsertRows(); - INFO("%s", qPrintable(message)); + SSRF_INFO("%s", qPrintable(message)); #if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) writeToAppLogFile(message); #endif -- cgit v1.2.3-70-g09d2