1 Star 0 Fork 0

尧小飞/cellphonedb

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
rabbit_logger.py 745 Bytes
一键复制 编辑 原始数据 按行查看 历史
import logging
import sys
class RabbitLogger:
def __init__(self):
self._logger = logging.getLogger(__name__)
formatter = logging.Formatter('[ ][QUEUE][%(asctime)s][%(levelname)s] %(message)s', "%d/%m/%y-%H:%M:%S")
handler = logging.StreamHandler(sys.stdout)
handler.setFormatter(formatter)
self._logger.addHandler(handler)
self._logger.setLevel(logging.INFO)
def __getattr__(self, item):
return getattr(self._logger, item)
class RabbitAdapter(logging.LoggerAdapter):
def process(self, msg, kwargs):
return '[{}] {}'.format(self.extra['job_id'], msg), kwargs
@classmethod
def logger_for(cls, logger, job_id):
return cls(logger, {'job_id': job_id})
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yao_xiao_fei2/cellphonedb.git
git@gitee.com:yao_xiao_fei2/cellphonedb.git
yao_xiao_fei2
cellphonedb
cellphonedb
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385