这里是你的项目描述
frame_logging的Python项目详细描述
此处是您的项目说明
文档
快速启动
安装帧日志:
pip install frame_logging
将其添加到已安装的应用程序中
INSTALLED_APPS=(...'frame_logging.apps.FrameLoggingConfig',...)
- 创建一个类以格式化额外的日志记录Kwargs
#classFrameFormatterExample(FrameFormatter):# format methods@classmethoddefget_format_behaviour(cls):returnOrderedDict([('customer_id',cls.format_customer_id),])@classmethoddefformat_customer_id(cls,customer_id):return"customer_id={}".format(customer_id)# then if you need to, you can add new method to transform extra kwargs# transform methods@classmethoddefget_transform_kwargs_methods(cls):return{'order':cls.transform_order,}@classmethoddeftransform_order(cls,order,**kwargs):kwargs['customer_id']=order.customer['id']returnkwargs
- 在settings.py中配置frame loggin
# mandatory, if you do not priovide a formatter the app will crashFRAME_FORMATTER=FrameFormatterExample()# optionnal, default = ' - 'FRAME_SEPARATOR='+'
- 使用:
importframe_logging.logaslogclassOrder(object):def__init__(self):self.customer={'id':1}log.info('Renewed contract %s','test',order=order)# 'Renewed contract test - customer_id=1'))
功能
- 待办事项
运行测试
代码真的有用吗?
source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install tox (myenv) $ tox
历史记录
0.1.0(2017-10-26)
- pypi上的第一个版本。