Issue #8117: logging: Improved algorithm for computing initial rollover time.
This commit is contained in:
parent
654ea3713e
commit
9098ee4360
|
@ -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):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue