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: traceback from logging is unusable.
Type: enhancement Stage: patch review
Components: Library (Lib) Versions: Python 3.1, Python 3.2, Python 2.7, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: methane, vinay.sajip
Priority: normal Keywords: patch

Created on 2010-02-07 05:10 by methane, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
logging_show_file_and_line.patch methane, 2010-02-07 05:12
Messages (3)
msg98981 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2010-02-07 05:10
When exception raised in logging, traceback is shown but it doesn't tell
me which logging code cause the error.

$ cat unusable_traceback.py 
import logging
logging.warn('%s %s', 1) # not enough arguments.

$ python unusable_traceback.py 
Traceback (most recent call last):
  File "/usr/lib/python2.6/logging/__init__.py", line 768, in emit
    msg = self.format(record)
  File "/usr/lib/python2.6/logging/__init__.py", line 648, in format
    return fmt.format(record)
  File "/usr/lib/python2.6/logging/__init__.py", line 436, in format
    record.message = record.getMessage()
  File "/usr/lib/python2.6/logging/__init__.py", line 306, in getMessage
    msg = msg % self.args
TypeError: not enough arguments for format string
msg98982 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2010-02-07 05:12
This patch shows filename and lineno.
I can specify my wrong logging code with this patch.
msg98996 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2010-02-07 12:59
Fix (slightly modified version of patch) checked into trunk (r78081), thanks Inada Naoki!
History
Date User Action Args
2022-04-11 14:56:57adminsetgithub: 52117
2010-02-07 12:59:25vinay.sajipsetstatus: open -> closed
resolution: fixed
messages: + msg98996
2010-02-07 08:20:07r.david.murraysetversions: - Python 2.5
nosy: + vinay.sajip

priority: normal
type: behavior -> enhancement
stage: patch review
2010-02-07 05:12:43methanesetfiles: + logging_show_file_and_line.patch
keywords: + patch
messages: + msg98982
2010-02-07 05:10:16methanecreate