diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2013-09-06 10:24:08 +0100 |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2013-09-06 10:24:08 +0100 |
commit | fb03696fdabeb850cdc714cd1abb45f6d93fcdf6 (patch) | |
tree | 8b64cf92ffccaba8329f4fac0aa5992be41aa4ca /Lib/logging | |
parent | 6d7e29651cf6a2232d66e47974c522cc2927a6c2 (diff) | |
download | cpython-git-fb03696fdabeb850cdc714cd1abb45f6d93fcdf6.tar.gz |
Issue #18941: Respected delay when doing rollover.
Diffstat (limited to 'Lib/logging')
-rw-r--r-- | Lib/logging/__init__.py | 1 | ||||
-rw-r--r-- | Lib/logging/handlers.py | 13 |
2 files changed, 5 insertions, 9 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index 1a622a3d07..0e8e3ddde0 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -893,6 +893,7 @@ class FileHandler(StreamHandler): self.baseFilename = os.path.abspath(filename) self.mode = mode self.encoding = encoding + self.delay = delay if delay: #We don't open the stream, but we still need to call the #Handler constructor to set level, formatter, lock etc. diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index 8a813d3e37..c45a3132ba 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -140,8 +140,8 @@ class RotatingFileHandler(BaseRotatingHandler): # Issue 18940: A file may not have been created if delay is True. if os.path.exists(self.baseFilename): os.rename(self.baseFilename, dfn) - #print "%s -> %s" % (self.baseFilename, dfn) - self.stream = self._open() + if not self.delay: + self.stream = self._open() def shouldRollover(self, record): """ @@ -349,15 +349,10 @@ class TimedRotatingFileHandler(BaseRotatingHandler): if os.path.exists(self.baseFilename): os.rename(self.baseFilename, dfn) if self.backupCount > 0: - # find the oldest log file and delete it - #s = glob.glob(self.baseFilename + ".20*") - #if len(s) > self.backupCount: - # s.sort() - # os.remove(s[0]) for s in self.getFilesToDelete(): os.remove(s) - #print "%s -> %s" % (self.baseFilename, dfn) - self.stream = self._open() + if not self.delay: + self.stream = self._open() newRolloverAt = self.computeRollover(currentTime) while newRolloverAt <= currentTime: newRolloverAt = newRolloverAt + self.interval |