-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlog.py
42 lines (35 loc) · 1009 Bytes
/
log.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
#!/usr/bin/env python
from xtermcolor import colorize
def enum(**enums):
return type('Enum', (), enums)
ansi_color= enum(
green=2,
blue = 69,
red = 5,
cyan=30,
purple=26,
orange=166,
light_green=154
)
def log(message, type = None, ansi= ansi_color.blue, tag = ''):
message = message.encode("ascii", errors="ignore").decode()
if type == 'info':
print(colorize(message, ansi = ansi_color.blue))
elif type == 'success':
print(colorize(message, ansi = ansi_color.green))
elif type == 'warning':
print(colorize(message, ansi = ansi_color.orange))
elif type == 'error':
print(colorize(message, ansi = ansi_color.red))
elif type == 'custom':
print(colorize(message, ansi = ansi))
else:
print(message)
def green(message):
print(colorize(message, ansi = ansi_color.green))
def red(message):
print(colorize(message, ansi = ansi_color.red))
def blue(message):
print(colorize(message, ansi = ansi_color.blue))
def orange(message):
print(colorize(message, ansi = ansi_color.orange))