代码拉取完成,页面将自动刷新
#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()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。