Home >Backend Development >Python Tutorial >python自动化工具日志查询分析脚本代码实现
受控节点slave.py
def all_log(self,reg):
logs=''
for f in self.file_list:
logs+='\n'+self.log_match(f,reg)
return logs
def log_match(self,f,reg):
log_result='------------------------'+f+'------------------------'+'\n'
fo=open(f,'r')
line=fo.readline()
rp=re.compile(reg)
while line!='':
log_match=rp.match(line)
if log_match:
log_result+='\n'+log_match.group()
line=fo.readline()
return log_result
if __name__=='__main__':
ds=Log()
主控节点master.py