From a7e06a4875dfa59f54e8a980ca745bbc53981474 Mon Sep 17 00:00:00 2001 From: Niklas Larsson Date: Mon, 28 Sep 2015 17:31:44 +0200 Subject: [PATCH] Rolling logfile when starting if needed --- src/RollingFileAppender.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/RollingFileAppender.cpp b/src/RollingFileAppender.cpp index 714e926..80b2043 100644 --- a/src/RollingFileAppender.cpp +++ b/src/RollingFileAppender.cpp @@ -144,7 +144,17 @@ void RollingFileAppender::computeRollOverTime() { Q_ASSERT_X(!m_datePatternString.isEmpty(), "DailyRollingFileAppender::computeRollOverTime()", "No active date pattern"); - QDateTime now = QDateTime::currentDateTime(); + QDateTime now; + + QFileInfo fileInfo = QFileInfo(this->fileName()); + if(fileInfo.isFile()){ + now = fileInfo.lastModified(); + } + + if(!now.isValid() || now > QDateTime::currentDateTime()){ + now = QDateTime::currentDateTime(); + } + QDate nowDate = now.date(); QTime nowTime = now.time(); QDateTime start;