mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
rotate log file when it hits 10MB
This commit is contained in:
parent
9334bc37fa
commit
75f87201a2
1 changed files with 5 additions and 0 deletions
|
@ -800,6 +800,11 @@ and queue = 0""", intTime(), self.usn())
|
||||||
if not self._debugLog:
|
if not self._debugLog:
|
||||||
return
|
return
|
||||||
lpath = re.sub("\.anki2$", ".log", self.path)
|
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")
|
self._logHnd = open(lpath, "ab")
|
||||||
|
|
||||||
def _closeLog(self):
|
def _closeLog(self):
|
||||||
|
|
Loading…
Reference in a new issue