xdebug格式的缩进函数跟踪
xtrace的Python项目详细描述
此模块从调用时起将函数跟踪打印到标准输出:
import xtrace xtrace.start() ... xtrace.stop()
也可以从命令行调用xtrace作为模块:
python -m xtrace <script.py> [param] ...
或用作独立脚本:
python xtrace.py <script.py> [param] ...
输出格式受xdebug函数跟踪的启发,可能会 与其合并http://xdebug.org/docs/execution_trace以与兼容 php检查工具。但是我没有足够的时间来打磨它,所以感觉 如果你知道如何拉近他们,可以免费发送补丁。
此代码已发布到公共域中。享受吧!
历史记录
- 0.5 - fix major crash when function in executed script tried to read variables in its global scope
- 0.4 - added beep function which beeps in DEBUG mode when excited
- 0.3 - fix AttributeError when running from console (issue #2)
- 0.2 - added version info, support running from command line, moved main functions into a class to isolate used variables in local namespace
- 0.1 - initial release
学分
amaury forget d'arc,了解python内部的有价值的信息
调试
查看在标准之上产生的各种内部事件 python提供的数据,启用调试选项:
import xtrace xtrace.DEBUG = True
这将为每个有趣的事件调用beepfunctiton。随便吧 用自己的方法覆盖它(monkeypatch),以过滤消息、转发等。
已知的python错误
以意外方式影响跟踪输出的python错误:
- http://bugs.python.org/issue15005(仅限python 2,linux)
- 从子进程调用捕获的stdout已损坏 在打印到屏幕的跟踪功能下