多进程旋转文件处理程序
mrfh的Python项目详细描述
说明
多处理rotatingfilehandler是 日志记录模块的RotatingFileHandler 它使用基于文件的锁提供了一个进程安全的旋转日志文件处理程序。
文档
安装
安装:
$ pip install mrfh
快速启动
你曾经拥有的:
fromlogging.handlersimportRotatingFileHandlerlogger=logging.getLogger('my_logger')handler=RotatingFileHandler('my_log.log',maxBytes=2000,backupCount=10)logger.addHandler(handler)logger.debug('Some debug message!')
您现在可以拥有:
frommrfhimportMultiprocessRotatingFileHandlerlogger=logging.getLogger('my_logger')handler=MultiprocessRotatingFileHandler('my_log.log',maxBytes=2000,backupCount=10)logger.addHandler(handler)logger.debug('Some debug message!')
你的旋转文件处理程序现在是安全的!
测试
运行测试:
python setup.py test
学分
大致上是基于已经失效的ConcurrentLogHandler。
许可证
开源麻省理工许可证。