我用信息/警告和调试消息编写了自己的 debugger.py。
见:https ://github.com/unixunion/toolbox/blob/master/python/debugger.py
我还使用回溯来遍历堆栈,例如:
except Exception, e:
# capture the traceback data
exc_type, exc_value, exc_traceback = sys.exc_info()
warningMsg("-14 %s" % str(e))
warningMsg("Exec Traceback")
traceback.print_tb(exc_traceback, limit=1, file=sys.stdout)
warningMsg("Exception")
traceback.print_exception(exc_type, exc_value, exc_traceback, limit=2, file=sys.stdout)
raise
给出如下结果:
WARNING fabfile.py:76 glassfish_deploy()-14 cannot concatenate 'str' and 'float' objects
WARNING fabfile.py:77 glassfish_deploy()Exec Traceback
File "/home/marzubus/go-agent-scripts/fabfile.py", line 52, in glassfish_deploy oiled = gfOil(**kwargs)
WARNING fabfile.py:79 glassfish_deploy()Exception
Traceback (most recent call last): File "/home/marzubus/go-agent-scripts/fabfile.py", line 52, in glassfish_deploy
oiled = gfOil(**kwargs)
File "/home/marzubus/go-agent-scripts/oilon/gfdeployer.py", line 37, in __init__
self.tmpDirectory = '/tmp/' + self.domainName + self.time
TypeError: cannot concatenate 'str' and 'float' objects
基根