[ python-Bugs-979252 ] Trap OSError when calling
RotatingFileHandler.doRollover
SourceForge.net
noreply at sourceforge.net
Thu Jun 24 16:43:03 EDT 2004
Bugs item #979252, was opened at 2004-06-24 15:43
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=979252&group_id=5470
Category: Python Library
Group: Feature Request
Status: Open
Resolution: None
Priority: 5
Submitted By: Richard T. Hewitt (hewittr)
Assigned to: Nobody/Anonymous (nobody)
Summary: Trap OSError when calling RotatingFileHandler.doRollover
Initial Comment:
I use the RotatingFileHandler in most of my scripts. The
script will crash if the RotatingFileHandler encounters a
locked log file.
I would like to see something like:
def emit(self, record):
"""
Emit a record.
Output the record to the file, catering for rollover
as described
in __init__().
"""
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
if self.stream.tell() + len(msg) >= self.maxBytes:
try:
self.doRollover()
except Exception:
logging.FileHandler.emit(self, 'Failed to
doRollover.')
logging.FileHandler.emit(self, record)
My version of Python (2.3.2) had the wrong docstring as
well, referring to a non-existent setRollover.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=979252&group_id=5470
More information about the Python-bugs-list
mailing list