-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathutils.py
More file actions
32 lines (29 loc) · 943 Bytes
/
utils.py
File metadata and controls
32 lines (29 loc) · 943 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
class PyColors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
def colorize_log(log_level, msg, should_colorize=True):
"""
Returns a colored string to log
:param should_colorize: boolean that specifies if the log is to be colorized
:param log_level: level of message to logged
:param msg: message to be logged
:return:
"""
colorize_log_dict = {
"NORMAL": PyColors.ENDC,
"WARNING": PyColors.WARNING,
"SUCCESS": PyColors.OKGREEN,
"FAIL": PyColors.FAIL,
"RESET": PyColors.ENDC
}
if should_colorize:
if log_level in colorize_log_dict:
return colorize_log_dict[str(log_level)] + msg + colorize_log_dict['RESET']
return colorize_log_dict["NORMAL"] + msg + colorize_log_dict["RESET"]
return msg