-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog_analyzer.py
More file actions
38 lines (26 loc) · 823 Bytes
/
Copy pathlog_analyzer.py
File metadata and controls
38 lines (26 loc) · 823 Bytes
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
info_count = 0
warning_count = 0
error_count = 0
errors = []
try:
with open("robot_log.txt", "r") as file:
for line in file:
line.strip()
if "INFO" in line:
info_count += 1
elif "WARNING" in line:
warning_count += 1
elif "ERROR" in line:
error_count += 1
#getting the actual error form log line
parts = line.split("ERROR ", 1)
error_message = parts[1]
errors.append(error_message)
print("INFO:", info_count)
print("WARNING:", warning_count)
print("ERROR:", error_count)
print("\nErrors:")
for error in errors:
print("-", error)
except FileNotFoundError:
print("Error: robot_log.txt was not found.")