[Python-checkins] r68830 - in python/branches/release26-maint/Lib/logging: __init__.py handlers.py

vinay.sajip python-checkins at python.org
Wed Jan 21 00:20:02 CET 2009


Author: vinay.sajip
Date: Wed Jan 21 00:20:02 2009
New Revision: 68830

Log:
Issue 5013: Fixed bug in FileHandler when delay was set - added fix for RotatingFileHandler and changed header comment slightly.

Modified:
   python/branches/release26-maint/Lib/logging/__init__.py
   python/branches/release26-maint/Lib/logging/handlers.py

Modified: python/branches/release26-maint/Lib/logging/__init__.py
==============================================================================
--- python/branches/release26-maint/Lib/logging/__init__.py	(original)
+++ python/branches/release26-maint/Lib/logging/__init__.py	Wed Jan 21 00:20:02 2009
@@ -18,9 +18,6 @@
 Logging package for Python. Based on PEP 282 and comments thereto in
 comp.lang.python, and influenced by Apache's log4j system.
 
-Should work under Python versions >= 1.5.2, except that source line
-information is not available unless 'sys._getframe()' is.
-
 Copyright (C) 2001-2009 Vinay Sajip. All Rights Reserved.
 
 To use, simply 'import logging' and log away!

Modified: python/branches/release26-maint/Lib/logging/handlers.py
==============================================================================
--- python/branches/release26-maint/Lib/logging/handlers.py	(original)
+++ python/branches/release26-maint/Lib/logging/handlers.py	Wed Jan 21 00:20:02 2009
@@ -19,12 +19,9 @@
 based on PEP 282 and comments thereto in comp.lang.python, and influenced by
 Apache's log4j system.
 
-Should work under Python versions >= 1.5.2, except that source line
-information is not available unless 'sys._getframe()' is.
+Copyright (C) 2001-2009 Vinay Sajip. All Rights Reserved.
 
-Copyright (C) 2001-2008 Vinay Sajip. All Rights Reserved.
-
-To use, simply 'import logging' and log away!
+To use, simply 'import logging.handlers' and log away!
 """
 
 import logging, socket, types, os, string, cPickle, struct, time, re
@@ -141,6 +138,8 @@
         Basically, see if the supplied record would cause the file to exceed
         the size limit we have.
         """
+        if self.stream is None:                 # delay was set...
+            self.stream = self._open()
         if self.maxBytes > 0:                   # are we rolling over?
             msg = "%s\n" % self.format(record)
             self.stream.seek(0, 2)  #due to non-posix-compliant Windows feature
@@ -305,7 +304,8 @@
         then we have to get a list of matching filenames, sort them and remove
         the one with the oldest suffix.
         """
-        self.stream.close()
+        if self.stream:
+            self.stream.close()
         # get the time that this sequence started at and make it a TimeTuple
         t = self.rolloverAt - self.interval
         if self.utc:


More information about the Python-checkins mailing list