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.

classification
Title: logging.exception doesn't accept 'extra'
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: vinay.sajip Nosy List: flox, nedbat, python-dev, vinay.sajip
Priority: normal Keywords:

Created on 2012-08-02 21:52 by nedbat, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg167260 - (view) Author: Ned Batchelder (nedbat) * (Python triager) Date: 2012-08-02 21:52
The logging.exception method differs from .debug(), .info(), .warning(), .error() and .critical() in that it does not accept an `extra` keyword argument.  There seems to be no reason for this.

The docs are misleading about this. They say, "The arguments are interpreted as for debug()."

Changing exception() to this would take care of it::

    def exception(self, msg, *args, **kwargs):
        """
        Convenience method for logging an ERROR with exception information.
        """
        kwargs['exc_info'] = 1
        self.error(msg, *args, **kwargs)
msg167456 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-08-04 22:43
New changeset 322da186cced by Vinay Sajip in branch '2.7':
Issue #15541: Correct anomaly in logging.exception. Thanks to Ned Batchelder for the report.
http://hg.python.org/cpython/rev/322da186cced
msg167477 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2012-08-05 08:41
Python 3.2 was already fixed with changeset ba014543ed2c.

It would be nice to have some tests, though.
History
Date User Action Args
2022-04-11 14:57:33adminsetgithub: 59746
2012-08-05 08:41:41floxsetnosy: + flox
messages: + msg167477
2012-08-04 22:44:18vinay.sajipsetstatus: open -> closed
assignee: vinay.sajip
resolution: fixed
versions: - Python 3.2
2012-08-04 22:43:32python-devsetnosy: + python-dev
messages: + msg167456
2012-08-04 21:44:03r.david.murraysetnosy: + vinay.sajip
2012-08-02 21:52:12nedbatcreate