From 0cb77362e8ab06994661e6993a1476d481be67a2 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Sun, 17 Jun 2018 13:44:14 +0300 Subject: [PATCH] Always roll hifi-log.txt when starting. Otherwise the active log file ("hifi-log.txt") contains lines from both previous sessions and the current session, which is confusing. --- libraries/shared/src/shared/FileLogger.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/shared/src/shared/FileLogger.cpp b/libraries/shared/src/shared/FileLogger.cpp index 6a10629ee5..b64d08c0d8 100644 --- a/libraries/shared/src/shared/FileLogger.cpp +++ b/libraries/shared/src/shared/FileLogger.cpp @@ -30,7 +30,7 @@ signals: void rollingLogFile(QString newFilename); protected: - void rollFileIfNecessary(QFile& file, bool notifyListenersIfRolled = true); + void rollFileIfNecessary(QFile& file, bool force = false, bool notifyListenersIfRolled = true); virtual bool processQueueItems(const Queue& messages) override; private: @@ -79,12 +79,12 @@ FilePersistThread::FilePersistThread(const FileLogger& logger) : _logger(logger) // A file may exist from a previous run - if it does, roll the file and suppress notifying listeners. QFile file(_logger._fileName); if (file.exists()) { - rollFileIfNecessary(file, false); + rollFileIfNecessary(file, true, false); } } -void FilePersistThread::rollFileIfNecessary(QFile& file, bool notifyListenersIfRolled) { - if (file.size() > MAX_LOG_SIZE) { +void FilePersistThread::rollFileIfNecessary(QFile& file, bool force, bool notifyListenersIfRolled) { + if (force || (file.size() > MAX_LOG_SIZE)) { QString newFileName = getLogRollerFilename(); if (file.copy(newFileName)) { file.open(QIODevice::WriteOnly | QIODevice::Truncate);