Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logging.error('...', exc_info=True) should display upper frames, too #53673

Closed
guettli mannequin opened this issue Jul 30, 2010 · 6 comments
Closed

logging.error('...', exc_info=True) should display upper frames, too #53673

guettli mannequin opened this issue Jul 30, 2010 · 6 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@guettli
Copy link
Mannequin

guettli mannequin commented Jul 30, 2010

BPO 9427
Nosy @vsajip, @bitdancer

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/vsajip'
closed_at = <Date 2011-03-07.18:46:34.239>
created_at = <Date 2010-07-30.11:25:47.086>
labels = ['type-feature', 'library']
title = "logging.error('...', exc_info=True) should display upper frames, too"
updated_at = <Date 2015-06-09.06:09:15.602>
user = 'https://bugs.python.org/guettli'

bugs.python.org fields:

activity = <Date 2015-06-09.06:09:15.602>
actor = 'piotr.dobrogost'
assignee = 'vinay.sajip'
closed = True
closed_date = <Date 2011-03-07.18:46:34.239>
closer = 'vinay.sajip'
components = ['Library (Lib)']
creation = <Date 2010-07-30.11:25:47.086>
creator = 'guettli'
dependencies = []
files = []
hgrepos = []
issue_num = 9427
keywords = []
message_count = 6.0
messages = ['112063', '112064', '112067', '112955', '114973', '130281']
nosy_count = 5.0
nosy_names = ['vinay.sajip', 'guettli', 'stutzbach', 'r.david.murray', 'piotr.dobrogost']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue9427'
versions = ['Python 3.3']

@guettli
Copy link
Mannequin Author

guettli mannequin commented Jul 30, 2010

logging.error('...', exc_info=True) only displays the
frames downward. But I often need the upper frames, to debug a problem.

This example shows, that you don't see the "upper" frame in the stactrace. But that's information is important.

<pre>
import logging

def foo():
    try:
        raise Exception()
    except Exception, exc:
        logging.error('Exception occured: %s' % exc, exc_info=True)

def upper():
    foo()
upper()
</pre>
<pre>
===> python tmp/t.py
ERROR:root:Exception occured: 
Traceback (most recent call last):
  File "tmp/t.py", line 6, in foo
    raise Exception()
Exception
</pre>

@guettli guettli mannequin added the stdlib Python modules in the Lib dir label Jul 30, 2010
@guettli
Copy link
Mannequin Author

guettli mannequin commented Jul 30, 2010

Related: bpo-1553375

@guettli
Copy link
Mannequin Author

guettli mannequin commented Jul 30, 2010

I tested it only on python 2.6. Can someone please look at more reset versions?

@guettli
Copy link
Mannequin Author

guettli mannequin commented Aug 5, 2010

Until exc_info=True prints the current stack, I use this pattern:

import traceback

logging.error(u's...\nStack: %s' % (
''.join(traceback.format_stack())), exc_info=True)

@vsajip vsajip self-assigned this Aug 22, 2010
@vsajip
Copy link
Member

vsajip commented Aug 26, 2010

This also happens on later versions. Since 2.x is essentially frozen, this feature request can't be implemented in 2.x, so recategorising as a Python 3.2 issue.

Here, a change in logging will either duplicate code in traceback.py or print the upper frames above the "Traceback (most recent call last):" line, which is not ideal.

The best way to implement in logging would be to wait for the implementation of the patch in bpo-1553375, following which a change could be made in Formatter.formatException to invoke traceback.print_exception with the "fullstack" keyword parameter.

@vsajip vsajip added the type-feature A feature request or enhancement label Aug 26, 2010
@vsajip
Copy link
Member

vsajip commented Mar 7, 2011

I'll close this, assuming that the stack_info keyword parameter added to logging calls in 3.2 will be sufficient.

I also removed the dependency on 1553375, which would prevent closure.

@vsajip vsajip closed this as completed Mar 7, 2011
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant