From 915b760d54d072f1d6ad805a3a963dc7c0ec6f70 Mon Sep 17 00:00:00 2001 From: Jan Mulder Date: Tue, 18 Jul 2017 20:25:41 +0200 Subject: Android: truncate logfile and add date Trucate the logfile on open to remove any data from previous sessions. This confused me very much, as the new logfile started from the top, leaving old data on the bottom. Also added system date for easy reference. Signed-off-by: Jan Mulder --- mobile-widgets/qmlmanager.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'mobile-widgets/qmlmanager.cpp') diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index 5066c589a..b84b83430 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include "qt-models/divelistmodel.h" #include "qt-models/gpslistmodel.h" @@ -97,12 +98,14 @@ QMLManager::QMLManager() : m_locationServiceEnabled(false), #if defined(Q_OS_ANDROID) appLogFileName = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation).first() + "/subsurface.log"; appLogFile.setFileName(appLogFileName); - if (!appLogFile.open(QIODevice::ReadWrite)) { + if (!appLogFile.open(QIODevice::ReadWrite|QIODevice::Truncate)) { appLogFileOpen = false; - appendTextToLog("Failed to open logfile" + appLogFileName); + appendTextToLog("Failed to open logfile " + appLogFileName + + " at " + QDateTime::currentDateTime().toString()); } else { appLogFileOpen = true; - appendTextToLog("Successfully opened logfile" + appLogFileName); + appendTextToLog("Successfully opened logfile " + appLogFileName + + " at " + QDateTime::currentDateTime().toString()); } #endif appendTextToLog("Starting " + getUserAgent()); -- cgit v1.2.3-70-g09d2