从应用程序收集详细日志的简单方法!
logger-helper的Python项目详细描述
master分支的文档构建、测试和linting。
记录器助手
logger helper提供了一种在 申请。使用标准logging库和 修饰类、方法和函数(甚至在模块级进行 使用mod方法)获取应用程序的详细日志 正在执行:
Calling __main__.Test.add(a = 1, b = 2, c = 3) Returned 6 from __main__.Test.add Calling __main__.Test.subtract(a = 3, b = 2, c = 2) Returned -1 from __main__.Test.subtract Calling __main__.Test.divide_by_zero(a = 10) Exception ZeroDivisionError occurred, "division by zero"
安装
要安装Logger帮助程序包,请确保使用 分发包管理器,然后运行以下命令:
pip install logger-helper
基本用法
您可以立即开始使用LoggerHelper。
importloggingfromlogger_helperimportLoggerHelper# Perform your standard logging setup herelog=LoggerHelper(logging.getLogger(__name__),logging.DEBUG)# DONE! Start decorating your modules, classes and functions:@logclassMyClass:defmethod_1(self):passdefmethod_2(self):pass@logdeffunction():pass
有关详细信息,请务必阅读the documentation。如果你克隆这个 存储库并安装invoke,您可以使用 invoke serve-docs。