From 75f87201a22e402adeda4bb4092625f4ceb2638f Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 13 Nov 2013 17:00:20 +0900 Subject: [PATCH] rotate log file when it hits 10MB --- anki/collection.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/anki/collection.py b/anki/collection.py index 2bda2f64f..706c0ff78 100644 --- a/anki/collection.py +++ b/anki/collection.py @@ -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):