This repository was archived by the owner on Jun 13, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +53
-7
lines changed Expand file tree Collapse file tree 3 files changed +53
-7
lines changed Original file line number Diff line number Diff line change 219219 "datefmt" : "%Y-%m-%dT%H:%M:%S%z" ,
220220 "format" : '%(h)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"' ,
221221 },
222+ # "gunicorn_custom": {
223+ # "format": "[%(levelname)s] %(message)s [%(process)d] [%(asctime)s]",
224+ # "datefmt": "%Y-%m-%d %H:%M:%S %z",
225+ # },
222226 },
223227 "filters" : {
224228 "health_check_filter" : {"()" : "utils.logging_configuration.HealthCheckFilter" }
240244 "formatter" : "gunicorn_json" ,
241245 "class" : "logging.StreamHandler" ,
242246 "stream" : "ext://sys.stdout" , # Default is stderr
243- # "filters": ["health_check_filter"],
247+ "filters" : ["health_check_filter" ],
244248 },
249+ # "gunicorn-error-console": {
250+ # "level": "INFO",
251+ # "formatter": "gunicorn_custom",
252+ # "class": "logging.StreamHandler",
253+ # "stream": "ext://sys.stdout",
254+ # },
245255 },
246256 "loggers" : {
247257 "gunicorn.access" : {
248258 "level" : "INFO" ,
249259 "handlers" : ["json-gunicorn-console" ],
250260 },
251- "gunicorn.error" : {
252- "level" : "INFO" , # Adjust this to match your desired level
253- "handlers" : ["json-gunicorn-console" ],
254- },
261+ # "gunicorn.error": {
262+ # "level": "INFO",
263+ # "handlers": ["gunicorn-error-console"],
264+ # "propagate": False,
265+ # },
255266 },
256267}
257268
Original file line number Diff line number Diff line change 22
33# starts the development server using gunicorn
44# NEVER run production with the --reload option command
5- echo " Starting gunicorn in dev mode"
5+ echo " Starting gunicorn in dev mode dev.sh "
66
77_start_gunicorn () {
88 if [ -n " $PROMETHEUS_MULTIPROC_DIR " ]; then
@@ -24,7 +24,7 @@ _start_gunicorn() {
2424 pip install debugpy
2525 python -m debugpy --listen 0.0.0.0:12345 -m gunicorn codecov.wsgi:application --reload --bind 0.0.0.0:8000 --access-logfile ' -' --timeout " ${GUNICORN_TIMEOUT:- 600} " $suffix
2626 fi
27- gunicorn codecov.wsgi:application --reload --bind 0.0.0.0:8000 --access-logfile ' -' --timeout " ${GUNICORN_TIMEOUT:- 600} " $suffix
27+ gunicorn codecov.wsgi:application --log-level=info -- reload --bind 0.0.0.0:8000 --access-logfile ' -' --timeout " ${GUNICORN_TIMEOUT:- 600} " $suffix
2828}
2929
3030if [ -z " $1 " ];
Original file line number Diff line number Diff line change 1+ import logging
12import os
23
4+ from gunicorn .glogging import Logger
35from prometheus_client import multiprocess
46
57
68def child_exit (server , worker ):
79 if worker and worker .pid and "PROMETHEUS_MULTIPROC_DIR" in os .environ :
810 multiprocess .mark_process_dead (worker .pid )
11+
12+
13+ class CustomGunicornLogger (Logger ):
14+ def setup (self , cfg ):
15+ super ().setup (cfg )
16+ custom_format = "[%(levelname)s] %(message)s [%(process)d] [%(asctime)s]"
17+ date_format = "%Y-%m-%d %H:%M:%S %z"
18+ formatter = logging .Formatter (fmt = custom_format , datefmt = date_format )
19+
20+ # Update handlers with the custom formatter
21+ for handler in self .error_log .handlers :
22+ handler .setFormatter (formatter )
23+ for handler in self .access_log .handlers :
24+ handler .setFormatter (formatter )
25+
26+
27+ logconfig_dict = {
28+ "loggers" : {
29+ "gunicorn.error" : {
30+ "level" : "INFO" ,
31+ "handlers" : ["console" ],
32+ "propagate" : False ,
33+ },
34+ "gunicorn.access" : {
35+ "level" : "INFO" ,
36+ "handlers" : ["console" ],
37+ "propagate" : False ,
38+ },
39+ }
40+ }
41+
42+ # Update Gunicorn's `logger_class` to use the custom logger
43+ logger_class = CustomGunicornLogger
You can’t perform that action at this time.
0 commit comments