Skip to content

Commit

Permalink
clean up gunicorn.conf.py
Browse files Browse the repository at this point in the history
  • Loading branch information
JerrySentry committed Nov 19, 2024
1 parent 2ee753d commit 8cf9142
Showing 1 changed file with 1 addition and 33 deletions.
34 changes: 1 addition & 33 deletions gunicorn.conf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import logging
import os

from gunicorn.glogging import Logger
from prometheus_client import multiprocess


Expand All @@ -10,34 +8,4 @@ def child_exit(server, worker):
multiprocess.mark_process_dead(worker.pid)


class CustomGunicornLogger(Logger):
def setup(self, cfg):
super().setup(cfg)
custom_format = "[%(levelname)s] %(message)s [%(process)d] [%(asctime)s]"
date_format = "%Y-%m-%d %H:%M:%S %z"
formatter = logging.Formatter(fmt=custom_format, datefmt=date_format)

# Update handlers with the custom formatter
for handler in self.error_log.handlers:
handler.setFormatter(formatter)
for handler in self.access_log.handlers:
handler.setFormatter(formatter)


logconfig_dict = {
"loggers": {
"gunicorn.error": {
"level": "INFO",
"handlers": ["console"],
"propagate": False,
},
"gunicorn.access": {
"level": "INFO",
"handlers": ["console"],
"propagate": False,
},
}
}

# Update Gunicorn's `logger_class` to use the custom logger
logger_class = CustomGunicornLogger
loglevel = "info"

0 comments on commit 8cf9142

Please sign in to comment.