rotate log file when it hits 10MB

This commit is contained in:
Damien Elmes 2013-11-13 17:00:20 +09:00
parent 9334bc37fa
commit 75f87201a2

View File

@ -800,6 +800,11 @@ and queue = 0""", intTime(), self.usn())
if not self._debugLog:
return
lpath = re.sub("\.anki2$", ".log", self.path)
if os.path.exists(lpath) and os.path.getsize(lpath) > 10*1024*1024:
lpath2 = lpath + ".old"
if os.path.exists(lpath2):
os.unlink(lpath2)
os.rename(lpath, lpath2)
self._logHnd = open(lpath, "ab")
def _closeLog(self):