修补日志记录模块以接受PEP-3101格式语法
logging_unterpolation的Python项目详细描述
日志转换是一个非常简单的模块,它将修补内置的日志模块,以接受符合PEP-3101的字符串格式(使用str.format方法),并返回到接受原始字符串插值运算符(或“modulo”)
下面是一个基本示例:
>>> import logging >>> from logging_unterpolation import patch_logging >>> logging.basicConfig(level=logging.DEBUG) >>> logging.debug('test') DEBUG:root:test >>> logging.debug('%s', 'test') # example of built-in string interpolation in log messages DEBUG:root:test >>> patch_logging() >>> logging.debug('{0}', 'test') # format syntax not supported unless patched DEBUG:root:test