Issue #8117: logging: Improved algorithm for computing initial rollover time.

This commit is contained in:
Vinay Sajip 2010-03-12 06:01:21 +00:00
parent 654ea3713e
commit 9098ee4360
2 changed files with 8 additions and 2 deletions

View File

@ -25,7 +25,7 @@ To use, simply 'import logging.handlers' and log away!
"""
import logging, socket, os, cPickle, struct, time, re
from stat import ST_DEV, ST_INO
from stat import ST_DEV, ST_INO, ST_MTIME
try:
import codecs
@ -208,7 +208,11 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
self.extMatch = re.compile(self.extMatch)
self.interval = self.interval * interval # multiply by units requested
self.rolloverAt = self.computeRollover(int(time.time()))
if os.path.exists(filename):
t = os.stat(filename)[ST_MTIME]
else:
t = int(time.time())
self.rolloverAt = self.computeRollover(t)
def computeRollover(self, currentTime):
"""

View File

@ -24,6 +24,8 @@ Core and Builtins
Library
-------
- Issue #8117: logging: Improved algorithm for computing initial rollover time.
- Issue #6472: The xml.etree package is updated to ElementTree 1.3. The
cElementTree module is updated too.