mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-08 14:24:29 +02:00
ApiListener#RotateLogFile(): don't overwrite previous log
(cherry picked from commit 997d84bfa0b8c53144590547bcffdb6d30695e9b)
This commit is contained in:
parent
206fb222c0
commit
c55e4e122f
@ -1095,13 +1095,11 @@ void ApiListener::RotateLogFile()
|
|||||||
String oldpath = GetApiDir() + "log/current";
|
String oldpath = GetApiDir() + "log/current";
|
||||||
String newpath = GetApiDir() + "log/" + Convert::ToString(static_cast<int>(ts)+1);
|
String newpath = GetApiDir() + "log/" + Convert::ToString(static_cast<int>(ts)+1);
|
||||||
|
|
||||||
|
// If the log is being rotated more than once per second,
|
||||||
#ifdef _WIN32
|
// don't overwrite the previous one, but silently deny rotation.
|
||||||
_unlink(newpath.CStr());
|
if (!Utility::PathExists(newpath)) {
|
||||||
#endif /* _WIN32 */
|
(void) rename(oldpath.CStr(), newpath.CStr());
|
||||||
|
}
|
||||||
|
|
||||||
(void) rename(oldpath.CStr(), newpath.CStr());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApiListener::LogGlobHandler(std::vector<int>& files, const String& file)
|
void ApiListener::LogGlobHandler(std::vector<int>& files, const String& file)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user