-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogutil.py
More file actions
26 lines (22 loc) · 818 Bytes
/
logutil.py
File metadata and controls
26 lines (22 loc) · 818 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
import logging
import logging.config
# Simpler method that sets the level everywhere, then makes exclusions for specific loggers/libraries
logging.basicConfig(
# filename = 'src/log.txt',
format = "%(levelname) -10s %(asctime)s %(filename)s:%(lineno)s %(name)s.%(funcName)s | %(message)s",
level=logging.DEBUG
)
level_override = {
logging.INFO: {
'internal': [],
'external': [],
},
logging.WARNING: {
'internal': [],
'external': ['matplotlib', 'matplotlib.pyplot', 'PIL.PngImagePlugin',
'selenium', 'connectionpool', 'urllib3'],
}
}
for level, level_loggers in level_override.items():
for logger in level_loggers['internal'] + level_loggers['external']:
logging.getLogger(logger).setLevel(level)