From 4f391599b3eec79ef394d9f6ef39ed0d12381084 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Wed, 21 Feb 2018 16:20:29 +0500 Subject: [PATCH] UI: Fix old log files deleting. --- src/ui/util/logger.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ui/util/logger.cpp b/src/ui/util/logger.cpp index f2e8eb89..4a122f6b 100644 --- a/src/ui/util/logger.cpp +++ b/src/ui/util/logger.cpp @@ -10,7 +10,7 @@ #define LOGGER_FILE_PREFIX "log_fort_" #define LOGGER_FILE_SUFFIX ".txt" #define LOGGER_FILE_MAX_SIZE (1024 * 1024) -#define LOGGER_KEEP_FILES 9 +#define LOGGER_KEEP_FILES 6 static QtMessageHandler g_oldMessageHandler = nullptr; @@ -115,6 +115,8 @@ void Logger::writeLog(const QString &message, LogLevel level) // Create file when required to avoid empty files if (!m_file.isOpen()) { + checkLogFiles(); + if (!openLogFile()) { m_writing = false; return; @@ -129,7 +131,6 @@ void Logger::writeLog(const QString &message, LogLevel level) if (m_file.size() > LOGGER_FILE_MAX_SIZE) { closeLogFile(); // Too big file - checkLogFiles(); } m_writing = false;