这个包提供了一个标准的日志处理程序,它将日志记录写入dbglog。
spadl的Python项目详细描述
此包提供了一个标准的日志处理程序,用于写入日志 记录到DbgLog。
你可能对这个图书馆不感兴趣,除非你 为seznam.cz工作。
这个包中实现的类允许您使用 并编写使用标准python日志记录的代码,同时 时间利用dbglog。
安装
spad可以使用pypi中的pip(或easy_install)安装:
$ pip install spadl
或者,您可以下载并提取tarball并手动安装软件包:
$ python setup.py install
把包裹放在Python身上也可以。
示例用法
dbglog区分同一级别日志记录的严重性。 消息可以记录为D4(重要调试)或E1(小错误)。 所以spdl.dbgloghandler将记录器名称映射到这些严重性。
有定义的函数configure,它简化了 日志记录配置。所以基本用法可以类似于:
import spadl spadl.configure({ # Log records from the 'app' logger and its children will # be logged using the highest severity (D4, I4, W4, E4, F4). 'app': 4, # But log records from the 'app.request' (and its children) # will be logged using a lower severity (D3, I3, W3, E3, F3). 'app.request': 3, # Another severity for another loggers. 'rpc': 2, # Log records from the 'db.sql' logger will be ignored. 'db.sql': 0, # Specification of the default severity. If was not present here then # the default behaviour would be to ignore records from unknown loggers. '': 1, }) # Now use logging normally. logging.info('This will be recorded by DbgLog.')
或者,您可以使用logging.config包配置日志记录。 配置文件中logging.config.fileconfig的相关部分 功能类似于:
[handler_dbglog] class=spadl.DbgLogHandler level=NOTSET args=({'app': 4, 'app.request': 3, 'rpc': 2, '': 1},)
有关工作示例,请参见(并运行)example.py。