This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author palaviv
Recipients palaviv, vinay.sajip
Date 2016-04-06.20:03:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1459973017.82.0.820573021891.issue26705@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2016-04-06 20:03:38palavivsetrecipients: + palaviv, vinay.sajip
2016-04-06 20:03:37palavivsetmessageid: <1459973017.82.0.820573021891.issue26705@psf.upfronthosting.co.za>
2016-04-06 20:03:37palavivlinkissue26705 messages
2016-04-06 20:03:37palavivcreate