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
Comments
logging.error('...', exc_info=True) only displays the This example shows, that you don't see the "upper" frame in the stactrace. But that's information is important. <pre> 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> |
Related: bpo-1553375 |
I tested it only on python 2.6. Can someone please look at more reset versions? |
Until exc_info=True prints the current stack, I use this pattern: import traceback logging.error(u's...\nStack: %s' % ( |
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. |
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. |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: