summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2009-01-20 23:16:08 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2009-01-20 23:16:08 (GMT)
commitaecf36a0b532260d38297e323c978bf6f0be2c83 (patch)
treefa9d19835b7d1c6bb25bda163802e044d524cffa
parent5fb11b2b855b7ddfede281e69c701aa0fbc0a5b3 (diff)
downloadcpython-aecf36a0b532260d38297e323c978bf6f0be2c83.zip
cpython-aecf36a0b532260d38297e323c978bf6f0be2c83.tar.gz
cpython-aecf36a0b532260d38297e323c978bf6f0be2c83.tar.bz2
Issue 5013: Fixed bug in FileHandler when delay was set - added fix for RotatingFileHandler and changed header comment slightly.
-rw-r--r--Lib/logging/__init__.py3
-rw-r--r--Lib/logging/handlers.py18
2 files changed, 9 insertions, 12 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index d61c0f1..b265c21 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -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!
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
index 9668ebe..6b21bed 100644
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -1,4 +1,4 @@
-# Copyright 2001-2007 by Vinay Sajip. All Rights Reserved.
+# Copyright 2001-2009 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,
@@ -19,12 +19,9 @@ Additional handlers for the logging package for Python. The core package is
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
@@ -115,8 +112,8 @@ class RotatingFileHandler(BaseRotatingHandler):
"""
Do a rollover, as described in __init__().
"""
-
- self.stream.close()
+ if self.stream:
+ self.stream.close()
if self.backupCount > 0:
for i in range(self.backupCount - 1, 0, -1):
sfn = "%s.%d" % (self.baseFilename, i)
@@ -141,6 +138,8 @@ class RotatingFileHandler(BaseRotatingHandler):
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 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
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: