]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #18941: Respected delay when doing rollover.
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Fri, 6 Sep 2013 09:25:31 +0000 (10:25 +0100)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Fri, 6 Sep 2013 09:25:31 +0000 (10:25 +0100)
Lib/logging/__init__.py
Lib/logging/handlers.py

index fa03f78ccee7c33e87689cffdcb660353bde78f1..4cef66fa139ea72823329c9a50e509990c65725a 100644 (file)
@@ -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!
 """
@@ -957,6 +957,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.
index f0f634e8d38f2f63e97693d2a70d8ad33bc8ff54..ddec7dd9d01c63395fabe97e9da730c9584976af 100644 (file)
@@ -174,7 +174,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):
         """
@@ -382,7 +383,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