diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2010-03-12 06:01:21 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2010-03-12 06:01:21 (GMT) |
commit | 9098ee43607340769d1dddf88522cc1bf9b1788f (patch) | |
tree | cffc00dfedafbbb92e0be2e68deed9c2d79ce56a /Lib/logging | |
parent | 654ea3713e12a061f39db5b0e45e15d37a140c10 (diff) | |
download | cpython-9098ee43607340769d1dddf88522cc1bf9b1788f.zip cpython-9098ee43607340769d1dddf88522cc1bf9b1788f.tar.gz cpython-9098ee43607340769d1dddf88522cc1bf9b1788f.tar.bz2 |
Issue #8117: logging: Improved algorithm for computing initial rollover time.
Diffstat (limited to 'Lib/logging')
-rw-r--r-- | Lib/logging/handlers.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index 8f890bc..30af6f2 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -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): """ |