3
0
Fork 0
mirror of https://github.com/lubosz/overte.git synced 2025-04-27 14:15:28 +02:00

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.
This commit is contained in:
Oren Hurvitz 2018-06-17 13:44:14 +03:00
parent 3c081c4bf8
commit 0cb77362e8

View file

@ -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);