-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogging_config.py
More file actions
36 lines (31 loc) · 959 Bytes
/
Copy pathlogging_config.py
File metadata and controls
36 lines (31 loc) · 959 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
import colorlog
import logging
def setup_logging():
handler = colorlog.StreamHandler()
formatter = colorlog.ColoredFormatter(
'%(purple)s%(asctime)s - %(log_color)s%(levelname)-8s - %(module)-8s - %(white)s%(message)s',
datefmt='%Y-%m-%d %H:%M:%S',
log_colors={
'DEBUG': 'green',
'INFO': 'cyan',
'WARNING': 'yellow',
'ERROR': 'red',
'CRITICAL': 'purple'
},
secondary_log_colors={
'message': {
'DEBUG': 'blue',
'INFO': 'white',
'WARNING': 'yellow',
'ERROR': 'red',
'CRITICAL': 'purple'
}
},
style='%'
)
handler.setFormatter(formatter)
logger = colorlog.getLogger()
logger.addHandler(handler)
logger.setLevel(logging.INFO)
mlogger = logging.getLogger('matplotlib')
mlogger.setLevel(logging.WARNING)