当发生异常时,记录重要数据。
exterminator的Python项目详细描述
病虫害防治
bug是不好的,但在生产中发生的时候更糟,这就是为什么在发生异常时记录所有可能的数据是一个好主意。在
安装
pip3 install exterminator
使用
你有三个选择。在
作为一个装饰师
^{pr2}$作为上下文管理器
fromexterminatorimportExterminatorwithExterminator():# do stuff, you know the thing
全球
fromexterminatorimportExterminatorExterminator().globally()# that's it! now every exception that is not handled will be looged
重要提示
如果您要排除所有错误,上下文管理器和全局解决方案对您不起作用,唯一的选择是:
fromexterminatorimportExterminator@Exterminator()defmain_function():# do stuff that work or nottry:main_function()except:# do some stuff of you own...
- 项目
标签: