[Twisted-Python] passing exception object to log.err doesn't log traceback?
Paul Wiseman
poalman at gmail.com
Thu Nov 15 09:02:05 EST 2012
I was just looking at some logs and some of the errors logged without
tracebacks, I work out it was when I wasn't passing the error object to
log.err- Is this by design?
Here is some code which shows it logging and not logging the traceback
import os
from twisted.python import log
from twisted.python.logfile import DailyLogFile
logfile=
DailyLogFile.fromFullPath(os.path.join(os.path.dirname(__file__),"error.log"))
log.startLogging(logfile)
def zero_error():
1/0
def stack(x):
if not x:
zero_error()
else:
stack(x-1)
def work(x,pass_exception):
try:
stack(x)
except Exception as e:
log.err(e if pass_exception else None)
if __name__ == "__main__":
work(5,True) #Doesn't log traceback
work(5,False) #Does log
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20121115/cb165eb1/attachment.htm
More information about the Twisted-Python
mailing list