[ python-Bugs-995109 ] logging.handlers.RotatingFileHandler missing error handling

SourceForge.net noreply at sourceforge.net
Thu Jul 22 13:18:45 CEST 2004


Bugs item #995109, was opened at 2004-07-21 09:40
Message generated for change (Comment added) made by vsajip
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=995109&group_id=5470

Category: Python Library
Group: Python 2.3
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Simon Dahlbacka (sdahlbac)
Assigned to: Vinay Sajip (vsajip)
Summary: logging.handlers.RotatingFileHandler missing error handling

Initial Comment:
If i open('logfile','r') in one shell and in my program
use a RotatingFileHandler using the same 'logfile', then 

os.rename(self.baseFilename, dfn) # line 86 in handlers.py

will fail and no log open, thus subsequent logging
attempts will  trigger a ValueError and render the
application in an unusable state.
(File "C:\Python23\lib\logging\handlers.py", line 103,
in emit
    self.stream.seek(0, 2)  #due to non-posix-compliant
Windows feature
ValueError: I/O operation on closed file)

I would have created a patch, but I am unsure of what
the correct behaviour should be?

- one possibility would be to continue logging to the
same file (skip rollover), but that is not ideal behaviour

----------------------------------------------------------------------

>Comment By: Vinay Sajip (vsajip)
Date: 2004-07-22 11:18

Message:
Logged In: YES 
user_id=308438

Unfortunately, there is no ideal behaviour. There is a "fix" for 
this problem in CVS - the handler calls handleError() if an 
exception is raised during emitting. If raiseExceptions is true, 
the exception is propagated up. If not, the exception is 
swallowed silently. There is no one universally agreed way of 
dealing with something like this - the best approach is for the 
application developer to provide custom handling via an 
overridden handleError() method in a derived handler class.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=995109&group_id=5470


More information about the Python-bugs-list mailing list