-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolorlogs.py
More file actions
40 lines (33 loc) · 1.09 KB
/
colorlogs.py
File metadata and controls
40 lines (33 loc) · 1.09 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
import logzero as l0
DEF_STYLE = "SUCCESS"
def log(*msgs, STYLE = DEF_STYLE):
log_format = '%(color)s%(message)s%(end_color)s'
formatter = l0.LogFormatter(fmt=log_format)
l0.setup_default_logger(formatter=formatter)
msg =""
for m in msgs:
msg+=m
if (STYLE == "GREEN" or STYLE == "SUCCESS"):
l0.logger.info(str(msg))
elif (STYLE == "BLUE" or STYLE == "INFO"):
l0.logger.debug(str(msg))
elif (STYLE == "YELLOW" or STYLE == "WARNING"):
l0.logger.warning(str(msg))
elif (STYLE == "RED" or STYLE == "ERROR"):
l0.logger.error(str(msg))
else:
l0.logger.error(str("INVALID TYPE"))
print
def setDefaultStyle(STYLE = "SUCCESS"):
if (STYLE == "GREEN" or STYLE == "SUCCESS"):
DEF_STYLE = "SUCCESS"
elif (STYLE == "BLUE" or STYLE == "INFO"):
DEF_STYLE = "INFO"
elif (STYLE == "YELLOW" or STYLE == "WARNING"):
DEF_STYLE = "WARNING"
elif (STYLE == "RED" or STYLE == "ERROR"):
DEF_STYLE = "ERROR"
else:
pass
def test():
log("THIS IS A TEST MSG!", STYLE = "YELLOW")