1 Star 0 Fork 0

bluedream_pp/pythonFirstInHead

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
logAnalysis.py 1.19 KB
一键复制 编辑 原始数据 按行查看 历史
bluedream_pp 提交于 2018-01-04 10:50 . faeture:司机连续上线功能
#coding:UTF-8
import re
from node import Node
from node import nodeList
import json
import codecs
import sys
# reload(sys)
# sys.setdefaultencoding("utf-8")
class Formate_kettle_log:
def __init__(self,conf_path):
self._conf_path =conf_path
def formate_log(self):
conf = codecs.open(self._conf_path,"r","utf-8")
conf_object = json.load(conf)
pattern = re.compile(conf_object['regex'],re.S)
list = nodeList()
with codecs.open(conf_object['log_path'], 'r',"utf-8") as f:
for line in f.readlines():
for l in re.findall(pattern,line):
if conf_object['start_tag'] in l[conf_object['status_tag']]:
list.add(Node(l[conf_object['plugin_name']],l[conf_object['occur_time']],''))
elif conf_object['end_tag'] in l[conf_object['status_tag']]:
list._find_by_plugin_name(l[conf_object['plugin_name']]).end_time = l[conf_object['occur_time']]
with codecs.open('E:\out.log','w',"utf-8") as log:
for i in list.findExceed(conf_object['exceed']):
if i != None:
log.write(i.to_str()+'\n')
conf.close()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/bluedream_pp/pythonFirstInHead.git
git@gitee.com:bluedream_pp/pythonFirstInHead.git
bluedream_pp
pythonFirstInHead
pythonFirstInHead
master

搜索帮助