-
Notifications
You must be signed in to change notification settings - Fork 0
/
printlog.py
executable file
·49 lines (43 loc) · 1004 Bytes
/
printlog.py
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
#!/usr/bin/env python3
import sys
esc = "\x1b"
clear = esc + "[0m" + esc + "[39m"
bold = esc + "[1m"
dim = esc + "[2m"
cyan = esc + "[96m"
red = esc + "[91m"
move = clear + dim
info = clear + cyan
warn = clear + bold + red
f = open("log.txt", "r")
def get_header(line):
return line.split(" ")[0]
def p(line):
header = get_header(line)
if header == "[MOVE]":
print(move + line, end="")
if header == "[INFO]":
print(info + line, end="")
if header == "[WARN]":
print(warn + line, end="")
i = f.readline()
while i:
try:
mode = sys.argv[1]
except:
print("use all, move, info or warn!")
break
if mode == "all" or mode == "move":
p(i)
elif mode == "info":
if get_header(i) != "[MOVE]":
p(i)
elif mode == "warn":
if get_header(i) == "[WARN]":
p(i)
else:
print("use all, move, info or warn!")
break
i = f.readline()
f.close()
print(clear, end="")