-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgunicorn.conf.py
37 lines (29 loc) · 1.08 KB
/
gunicorn.conf.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
import logging
import gunicorn.glogging
import cdislogging
import gearbox.config
class CDISLogger(gunicorn.glogging.Logger):
"""
Initialize root and gunicorn loggers with cdislogging configuration.
"""
@staticmethod
def _remove_handlers(logger):
"""
Use Python's built-in logging module to remove all handlers associated
with logger (logging.Logger).
"""
while logger.handlers:
logger.removeHandler(logger.handlers[0])
def __init__(self, cfg):
"""
Apply cdislogging configuration after gunicorn has set up it's loggers.
"""
super().__init__(cfg)
self._remove_handlers(logging.getLogger())
cdislogging.get_logger(None, log_level="debug" if gearbox.config.DEBUG else "warn")
for logger_name in ["gunicorn", "gunicorn.error", "gunicorn.access"]:
self._remove_handlers(logging.getLogger(logger_name))
cdislogging.get_logger(
logger_name, log_level="debug" if gearbox.config.DEBUG else "info"
)
logger_class = CDISLogger