Traceback in Logging
skip at pobox.com
skip at pobox.com
Tue Jan 6 11:30:43 EST 2009
Kottiyath> I dont want the whole traceback. I just wanted to know where
Kottiyath> the log was generated from i.e. which procedure and which
Kottiyath> line.
The asyncore standard module has an undocumented compact_traceback()
function:
#!/usr/bin/env python
import asyncore
def f():
1/0
def g():
f()
def h():
g()
try:
h()
except ZeroDivisionError:
print asyncore.compact_traceback()[3]
Output looks like this:
% python f.py
[f.py|<module>|15] [f.py|h|12] [f.py|g|9] [f.py|f|6]
Might be of interest.
--
Skip Montanaro - skip at pobox.com - http://smontanaro.dyndns.org/
More information about the Python-list
mailing list