Skip to content

Commit

Permalink
Merge pull request #9999 from Icinga/reset-log-message-count-correctly
Browse files Browse the repository at this point in the history
ApiListener: Reset `m_LogMessageCount` when rotating
  • Loading branch information
julianbrost committed Feb 15, 2024
2 parents 9db1c4a + 6e66cd9 commit 7d1c887
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/remote/apilistener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1375,7 +1375,6 @@ void ApiListener::OpenLogFile()
}

m_LogFile = new StdioStream(fp.release(), true);
m_LogMessageCount = 0;
SetLogMessageTimestamp(Utility::GetTime());
}

Expand Down Expand Up @@ -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 '"
Expand Down

0 comments on commit 7d1c887

Please sign in to comment.