diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2013-09-06 09:26:48 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2013-09-06 09:26:48 (GMT) |
commit | f7b436ce8d69e1067cf2cb3769de93605b307327 (patch) | |
tree | 588cde0d7785261f19b31a0c28edb4c44b181428 /Lib/logging | |
parent | a92a3564a92834c354712229942f70e6e5620371 (diff) | |
parent | 43c6ef189955474001aad75d3b47d895180b2d42 (diff) | |
download | cpython-f7b436ce8d69e1067cf2cb3769de93605b307327.zip cpython-f7b436ce8d69e1067cf2cb3769de93605b307327.tar.gz cpython-f7b436ce8d69e1067cf2cb3769de93605b307327.tar.bz2 |
Closes #18941: Merged fix from 3.3.
Diffstat (limited to 'Lib/logging')
-rw-r--r-- | Lib/logging/__init__.py | 5 | ||||
-rw-r--r-- | Lib/logging/handlers.py | 6 |
2 files changed, 7 insertions, 4 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index 3ecce73..9359afb 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2001-2012 by Vinay Sajip. All Rights Reserved. +# Copyright 2001-2013 by Vinay Sajip. All Rights Reserved. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, @@ -18,7 +18,7 @@ Logging package for Python. Based on PEP 282 and comments thereto in comp.lang.python. -Copyright (C) 2001-2012 Vinay Sajip. All Rights Reserved. +Copyright (C) 2001-2013 Vinay Sajip. All Rights Reserved. To use, simply 'import logging' and log away! """ @@ -971,6 +971,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 b67a8ac..0ae6e45 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -172,7 +172,8 @@ class RotatingFileHandler(BaseRotatingHandler): if os.path.exists(dfn): os.remove(dfn) self.rotate(self.baseFilename, dfn) - self.stream = self._open() + if not self.delay: + self.stream = self._open() def shouldRollover(self, record): """ @@ -394,7 +395,8 @@ class TimedRotatingFileHandler(BaseRotatingHandler): if self.backupCount > 0: for s in self.getFilesToDelete(): os.remove(s) - self.stream = self._open() + if not self.delay: + self.stream = self._open() newRolloverAt = self.computeRollover(currentTime) while newRolloverAt <= currentTime: newRolloverAt = newRolloverAt + self.interval |