Issue 5013: Fixed bug in FileHandler when delay was set - added fix for RotatingFileHandler and changed header comment slightly.
This commit is contained in:
parent
b14043c1ec
commit
6268cbc771
|
@ -18,7 +18,7 @@
|
||||||
Logging package for Python. Based on PEP 282 and comments thereto in
|
Logging package for Python. Based on PEP 282 and comments thereto in
|
||||||
comp.lang.python, and influenced by Apache's log4j system.
|
comp.lang.python, and influenced by Apache's log4j system.
|
||||||
|
|
||||||
Copyright (C) 2001-2008 Vinay Sajip. All Rights Reserved.
|
Copyright (C) 2001-2009 Vinay Sajip. All Rights Reserved.
|
||||||
|
|
||||||
To use, simply 'import logging' and log away!
|
To use, simply 'import logging' and log away!
|
||||||
"""
|
"""
|
||||||
|
@ -43,8 +43,8 @@ except ImportError:
|
||||||
|
|
||||||
__author__ = "Vinay Sajip <vinay_sajip@red-dove.com>"
|
__author__ = "Vinay Sajip <vinay_sajip@red-dove.com>"
|
||||||
__status__ = "production"
|
__status__ = "production"
|
||||||
__version__ = "0.5.0.6"
|
__version__ = "0.5.0.7"
|
||||||
__date__ = "03 December 2008"
|
__date__ = "20 January 2009"
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
# Miscellaneous module data
|
# Miscellaneous module data
|
||||||
|
@ -737,7 +737,6 @@ class StreamHandler(Handler):
|
||||||
if strm is None:
|
if strm is None:
|
||||||
strm = sys.stderr
|
strm = sys.stderr
|
||||||
self.stream = strm
|
self.stream = strm
|
||||||
self.formatter = None
|
|
||||||
|
|
||||||
def flush(self):
|
def flush(self):
|
||||||
"""
|
"""
|
||||||
|
@ -792,10 +791,12 @@ class FileHandler(StreamHandler):
|
||||||
self.mode = mode
|
self.mode = mode
|
||||||
self.encoding = encoding
|
self.encoding = encoding
|
||||||
if delay:
|
if delay:
|
||||||
|
#We don't open the stream, but we still need to call the
|
||||||
|
#Handler constructor to set level, formatter, lock etc.
|
||||||
|
Handler.__init__(self)
|
||||||
self.stream = None
|
self.stream = None
|
||||||
else:
|
else:
|
||||||
stream = self._open()
|
StreamHandler.__init__(self, self._open())
|
||||||
StreamHandler.__init__(self, stream)
|
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
"""
|
"""
|
||||||
|
@ -827,8 +828,7 @@ class FileHandler(StreamHandler):
|
||||||
constructor, open it before calling the superclass's emit.
|
constructor, open it before calling the superclass's emit.
|
||||||
"""
|
"""
|
||||||
if self.stream is None:
|
if self.stream is None:
|
||||||
stream = self._open()
|
self.stream = self._open()
|
||||||
StreamHandler.__init__(self, stream)
|
|
||||||
StreamHandler.emit(self, record)
|
StreamHandler.emit(self, record)
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
|
@ -19,9 +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
|
based on PEP 282 and comments thereto in comp.lang.python, and influenced by
|
||||||
Apache's log4j system.
|
Apache's log4j system.
|
||||||
|
|
||||||
Copyright (C) 2001-2008 Vinay Sajip. All Rights Reserved.
|
Copyright (C) 2001-2009 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, os, pickle, struct, time, re
|
import logging, socket, os, pickle, struct, time, re
|
||||||
|
@ -112,8 +112,8 @@ class RotatingFileHandler(BaseRotatingHandler):
|
||||||
"""
|
"""
|
||||||
Do a rollover, as described in __init__().
|
Do a rollover, as described in __init__().
|
||||||
"""
|
"""
|
||||||
|
if self.stream:
|
||||||
self.stream.close()
|
self.stream.close()
|
||||||
if self.backupCount > 0:
|
if self.backupCount > 0:
|
||||||
for i in range(self.backupCount - 1, 0, -1):
|
for i in range(self.backupCount - 1, 0, -1):
|
||||||
sfn = "%s.%d" % (self.baseFilename, i)
|
sfn = "%s.%d" % (self.baseFilename, i)
|
||||||
|
@ -138,6 +138,8 @@ class RotatingFileHandler(BaseRotatingHandler):
|
||||||
Basically, see if the supplied record would cause the file to exceed
|
Basically, see if the supplied record would cause the file to exceed
|
||||||
the size limit we have.
|
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?
|
if self.maxBytes > 0: # are we rolling over?
|
||||||
msg = "%s\n" % self.format(record)
|
msg = "%s\n" % self.format(record)
|
||||||
self.stream.seek(0, 2) #due to non-posix-compliant Windows feature
|
self.stream.seek(0, 2) #due to non-posix-compliant Windows feature
|
||||||
|
@ -302,7 +304,8 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
|
||||||
then we have to get a list of matching filenames, sort them and remove
|
then we have to get a list of matching filenames, sort them and remove
|
||||||
the one with the oldest suffix.
|
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
|
# get the time that this sequence started at and make it a TimeTuple
|
||||||
t = self.rolloverAt - self.interval
|
t = self.rolloverAt - self.interval
|
||||||
if self.utc:
|
if self.utc:
|
||||||
|
|
17
Misc/NEWS
17
Misc/NEWS
|
@ -48,7 +48,7 @@ Core and Builtins
|
||||||
Martin von Löwis at
|
Martin von Löwis at
|
||||||
http://mail.python.org/pipermail/python-dev/2008-June/080579.html.
|
http://mail.python.org/pipermail/python-dev/2008-June/080579.html.
|
||||||
|
|
||||||
- Issue #4604: Some objects of the I/O library could still be used after
|
- Issue #4604: Some objects of the I/O library could still be used after
|
||||||
having been closed (for instance, a read() call could return some
|
having been closed (for instance, a read() call could return some
|
||||||
previously buffered data). Patch by Dmitry Vasiliev.
|
previously buffered data). Patch by Dmitry Vasiliev.
|
||||||
|
|
||||||
|
@ -137,6 +137,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #5013: Fixed a bug in FileHandler which occurred when the delay
|
||||||
|
parameter was set.
|
||||||
|
|
||||||
- Issue #4842: Always append a trailing 'L' when pickling longs using
|
- Issue #4842: Always append a trailing 'L' when pickling longs using
|
||||||
pickle protocol 0. When reading, the 'L' is optional.
|
pickle protocol 0. When reading, the 'L' is optional.
|
||||||
|
|
||||||
|
@ -146,7 +149,7 @@ Library
|
||||||
_check_logger_class from multiprocessing.
|
_check_logger_class from multiprocessing.
|
||||||
|
|
||||||
- Issue #3325: Remove python2.x try: except: imports for old cPickle from
|
- Issue #3325: Remove python2.x try: except: imports for old cPickle from
|
||||||
multiprocessing.
|
multiprocessing.
|
||||||
|
|
||||||
- Issue #4959: inspect.formatargspec now works for keyword only arguments
|
- Issue #4959: inspect.formatargspec now works for keyword only arguments
|
||||||
without defaults.
|
without defaults.
|
||||||
|
@ -183,8 +186,8 @@ Library
|
||||||
- Issue #3638: Remove functions from _tkinter module level that depend on
|
- Issue #3638: Remove functions from _tkinter module level that depend on
|
||||||
TkappObject to work with multiple threads.
|
TkappObject to work with multiple threads.
|
||||||
|
|
||||||
- Issue #4718: Adapt the wsgiref package so that it actually works with
|
- Issue #4718: Adapt the wsgiref package so that it actually works with
|
||||||
Python 3.x, in accordance with the `official amendments of the spec
|
Python 3.x, in accordance with the `official amendments of the spec
|
||||||
<http://www.wsgi.org/wsgi/Amendments_1.0>`_.
|
<http://www.wsgi.org/wsgi/Amendments_1.0>`_.
|
||||||
|
|
||||||
- Issue #4796: Added Decimal.from_float() and Context.create_decimal_from_float()
|
- Issue #4796: Added Decimal.from_float() and Context.create_decimal_from_float()
|
||||||
|
@ -202,10 +205,10 @@ Library
|
||||||
- Issue #4795: inspect.isgeneratorfunction() returns False instead of None when
|
- Issue #4795: inspect.isgeneratorfunction() returns False instead of None when
|
||||||
the function is not a generator.
|
the function is not a generator.
|
||||||
|
|
||||||
- Issue #4702: Throwing a DistutilsPlatformError instead of IOError in case
|
- Issue #4702: Throwing a DistutilsPlatformError instead of IOError in case
|
||||||
no MSVC compiler is found under Windows. Original patch by Philip Jenvey.
|
no MSVC compiler is found under Windows. Original patch by Philip Jenvey.
|
||||||
|
|
||||||
- Issue #4646: distutils was choking on empty options arg in the setup
|
- Issue #4646: distutils was choking on empty options arg in the setup
|
||||||
function. Original patch by Thomas Heller.
|
function. Original patch by Thomas Heller.
|
||||||
|
|
||||||
- Issue #3767: Convert Tk object to string in tkColorChooser.
|
- Issue #3767: Convert Tk object to string in tkColorChooser.
|
||||||
|
|
Loading…
Reference in New Issue