-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparsing_error.py
More file actions
60 lines (40 loc) · 1.03 KB
/
parsing_error.py
File metadata and controls
60 lines (40 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# -*- coding: UTF-8 -*-
'''
-flow
1. read_file
2. def make_log
2.1 make_dic
2.2 sort
2.3 print (Summary + Detail)
3. run
'''
#1. read_file : 각 라인을 리스트로 저장
origin_file = open('error_log')
Lines_file = origin_file.readlines()
#2. def make_log
def make_log(origin):
#2.1 make_dic
dic_errorlog = {}
for Oneline in origin:
#2.2 check_error
if Oneline.find('error') != -1 :
#parsing_2ed[0] = sort / parsing_2ed[1] = address
parsing_1st = Oneline.split('] ')
parsing_2ed = parsing_1st[3].split(': /')
if parsing_2ed[0] not in dic_errorlog:
dic_errorlog[parsing_2ed[0]] = {'list' : [] , 'count' : 0}
else:
dic_errorlog[parsing_2ed[0]]['list'].append(parsing_2ed[1])
dic_errorlog[parsing_2ed[0]]['count'] += 1
#2.3 print
print '[Summary]'
for keys in dic_errorlog:
print keys, dic_errorlog[keys]['count']
print '[Detail]'
print '-----------------'
for keys in dic_errorlog:
print keys
for each in dic_errorlog[keys]['list']:
print each
#3. run
make_log(Lines_file)