Skip to content

Commit

Permalink
fix: Avoid loading Django settings in Gunicorn (#3685)
Browse files Browse the repository at this point in the history
  • Loading branch information
khvn26 authored Mar 27, 2024
1 parent 9952424 commit 7c65445
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions api/util/logging.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import json
import logging
import os
import sys
from datetime import datetime
from typing import Any

from django.conf import settings
from gunicorn.config import Config
from gunicorn.glogging import Logger as GunicornLogger

Expand Down Expand Up @@ -54,7 +54,7 @@ def get_json_record(self, record: logging.LogRecord) -> dict[str, Any]:
class GunicornJsonCapableLogger(GunicornLogger):
def setup(self, cfg: Config) -> None:
super().setup(cfg)
if settings.LOG_FORMAT == "json":
if os.getenv("LOG_FORMAT") == "json":
self._set_handler(
self.error_log,
cfg.errorlog,
Expand Down

0 comments on commit 7c65445

Please sign in to comment.