From 6e66cd9afffdfebd7fdfcc779e64cf8e966fd44a Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Fri, 9 Feb 2024 16:42:53 +0100 Subject: [PATCH] ApiListener: Reset `m_LogMessageCount` when rotating Closing and re-opening that very same log file shouldn't reset the counter, otherwise some log files may exceed the max limit per file as their offset indicator is reset each time they are re-opened. --- lib/remote/apilistener.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/remote/apilistener.cpp b/lib/remote/apilistener.cpp index 85443e218..b71250376 100644 --- a/lib/remote/apilistener.cpp +++ b/lib/remote/apilistener.cpp @@ -1375,7 +1375,6 @@ void ApiListener::OpenLogFile() } m_LogFile = new StdioStream(fp.release(), true); - m_LogMessageCount = 0; SetLogMessageTimestamp(Utility::GetTime()); } @@ -1405,6 +1404,9 @@ void ApiListener::RotateLogFile() if (!Utility::PathExists(newpath)) { try { Utility::RenameFile(oldpath, newpath); + + // We're rotating the current log file, so reset the log message counter as well. + m_LogMessageCount = 0; } catch (const std::exception& ex) { Log(LogCritical, "ApiListener") << "Cannot rotate replay log file from '" << oldpath << "' to '"