Skip to content

Commit

Permalink
Simplify client fetching in django.handlers.LoggingHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
basepi committed Mar 9, 2021
1 parent c83864c commit 62d9661
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions elasticapm/contrib/django/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
import sys
import warnings

from django.apps import apps
from django.conf import settings as django_settings

from elasticapm import get_client
from elasticapm.handlers.logging import LoggingHandler as BaseLoggingHandler
from elasticapm.utils.logging import get_logger

Expand All @@ -51,13 +51,7 @@ def __init__(self, level=logging.NOTSET):

@property
def client(self):
try:
app = apps.get_app_config("elasticapm.contrib.django")
if not app.client:
logger.warning("Can't send log message to APM server, Django apps not initialized yet")
return app.client
except LookupError:
logger.warning("Can't send log message to APM server, elasticapm.contrib.django not in INSTALLED_APPS")
return get_client()

def _emit(self, record, **kwargs):
from elasticapm.contrib.django.middleware import LogMiddleware
Expand Down

0 comments on commit 62d9661

Please sign in to comment.