[New-bugs-announce] [issue26705] logging.Handler.handleError should be called from logging.Handler.handle
Aviv Palivoda
report at bugs.python.org
Wed Apr 6 16:03:37 EDT 2016
New submission from Aviv Palivoda:
Currently all the stdlib logging handlers (except BufferingHandler) emit method have the following structure:
def emit(self, record):
try:
// do the emit
except Exception:
self.handleError(record)
I suggest changing this so that the handle method will do the exception handling of the emit:
def handle(self, record):
rv = self.filter(record)
if rv:
self.acquire()
try:
self.emit(record)
except Exception:
self.handleError(record)
finally:
self.release()
return rv
Now the emit() method can be override without the need to handle it's own exceptions.
I think this is more clear with the current documentation as well. For example in the handleError function it says that "This method should be called from handlers when an exception is encountered during an emit() call". In addition in the only example that implement the emit() function https://docs.python.org/3/howto/logging-cookbook.html#speaking-logging-messages there is no error handling at all.
----------
components: Library (Lib)
files: logging-handle-error.patch
keywords: patch
messages: 262962
nosy: palaviv, vinay.sajip
priority: normal
severity: normal
status: open
title: logging.Handler.handleError should be called from logging.Handler.handle
type: behavior
versions: Python 3.6
Added file: http://bugs.python.org/file42381/logging-handle-error.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26705>
_______________________________________
More information about the New-bugs-announce
mailing list