From 06432e84c78acb1cc249af87ca477c7c9ba7855b Mon Sep 17 00:00:00 2001 From: Marijn Kampf Date: Tue, 2 Apr 2024 09:57:48 +0100 Subject: [PATCH] DPM 199 Data Hub API logging (#5304) * Change logging to ASIM formatter * Update common_logging.py --- config/settings/common_logging.py | 17 +++++++++-------- requirements-dev.txt | 14 +++++--------- requirements.in | 2 +- requirements.txt | 30 +++++++++++++++++++++--------- 4 files changed, 36 insertions(+), 27 deletions(-) diff --git a/config/settings/common_logging.py b/config/settings/common_logging.py index 7e3675f65..20e8edca1 100644 --- a/config/settings/common_logging.py +++ b/config/settings/common_logging.py @@ -1,6 +1,7 @@ import sys import sentry_sdk -from django_log_formatter_ecs import ECSFormatter +from django_log_formatter_asim import ASIMFormatter + from sentry_sdk.integrations.django import DjangoIntegration from config.settings.common import * @@ -13,30 +14,30 @@ 'verbose': { 'format': '%(asctime)s [%(levelname)s] [%(name)s] %(message)s' }, - 'ecs_formatter': { - '()': ECSFormatter, + "asim_formatter": { + "()": ASIMFormatter, }, }, 'handlers': { - 'ecs': { + 'asim': { 'class': 'logging.StreamHandler', - 'formatter': 'ecs_formatter', + 'formatter': 'asim_formatter', 'stream': sys.stdout, }, }, 'root': { 'level': 'INFO', - 'handlers': ['ecs'], + 'handlers': ['asim'], }, 'loggers': { 'django': { 'level': 'INFO', - 'handlers': ['ecs'], + 'handlers': ['asim'], 'propagate': False, }, 'django.db.backends': { 'level': 'ERROR', - 'handlers': ['ecs'], + 'handlers': ['asim'], 'propagate': False, }, }, diff --git a/requirements-dev.txt b/requirements-dev.txt index fd2f41b39..9a7ca5bb0 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -69,6 +69,7 @@ django==4.2.14 # django-extensions # django-filter # django-js-asset + # django-log-formatter-asim # django-redis # django-reversion # djangorestframework @@ -84,11 +85,9 @@ django-extensions==3.2.3 # via -r requirements.in django-filter==24.2 # via -r requirements.in -django-ipware==3.0.7 - # via django-log-formatter-ecs django-js-asset==2.0.0 # via django-mptt -django-log-formatter-ecs==0.0.5 +django-log-formatter-asim==0.0.4 # via -r requirements.in django-mptt==0.16.0 # via -r requirements.in @@ -183,14 +182,10 @@ jmespath==1.0.1 # via # boto3 # botocore -kubi-ecs-logger==0.1.2 - # via django-log-formatter-ecs mail-parser==3.15.0 # via -r requirements.in markupsafe==2.1.2 # via werkzeug -marshmallow==3.19.0 - # via kubi-ecs-logger matplotlib-inline==0.1.6 # via ipython mccabe==0.7.0 @@ -218,7 +213,6 @@ opensearch-py==2.6.0 packaging==22.0 # via # build - # marshmallow # pytest # python-redis-rate-limit pandas==2.2.2 @@ -240,7 +234,9 @@ platformdirs==2.6.0 pluggy==1.5.0 # via pytest pre-commit==3.7.1 - # via -r requirements-dev.in + # via + # -r requirements-dev.in + # django-log-formatter-asim prompt-toolkit==3.0.41 # via ipython psycogreen==1.0.2 diff --git a/requirements.in b/requirements.in index 280ceb8d4..f04571088 100644 --- a/requirements.in +++ b/requirements.in @@ -6,7 +6,7 @@ django-csp==3.8 django-environ==0.11.2 django-extensions==3.2.3 django-filter==24.2 -django-log-formatter-ecs==0.0.5 +django-log-formatter-asim==0.0.4 django-mptt==0.16.0 django-pglocks==1.0.4 django-reversion==5.0.12 diff --git a/requirements.txt b/requirements.txt index f6608136e..cbcb38095 100644 --- a/requirements.txt +++ b/requirements.txt @@ -32,6 +32,8 @@ certifi==2024.7.4 # opensearch-py # requests # sentry-sdk +cfgv==3.4.0 + # via pre-commit chardet==5.2.0 # via -r requirements.in charset-normalizer==2.1.1 @@ -40,6 +42,8 @@ click==8.1.3 # via rq crontab==1.0.0 # via rq-scheduler +distlib==0.3.8 + # via virtualenv django==4.2.14 # via # -r requirements.in @@ -49,6 +53,7 @@ django==4.2.14 # django-extensions # django-filter # django-js-asset + # django-log-formatter-asim # django-redis # django-reversion # djangorestframework @@ -64,11 +69,9 @@ django-extensions==3.2.3 # via -r requirements.in django-filter==24.2 # via -r requirements.in -django-ipware==3.0.7 - # via django-log-formatter-ecs django-js-asset==2.0.0 # via django-mptt -django-log-formatter-ecs==0.0.5 +django-log-formatter-asim==0.0.4 # via -r requirements.in django-mptt==0.16.0 # via -r requirements.in @@ -88,6 +91,8 @@ elastic-apm==6.22.3 # via -r requirements.in events==0.5 # via opensearch-py +filelock==3.13.3 + # via virtualenv freezegun==1.5.1 # via rq-scheduler frozenlist==1.3.3 @@ -100,6 +105,8 @@ greenlet==3.0.1 # via gevent icalendar==5.0.13 # via -r requirements.in +identify==2.5.35 + # via pre-commit idna==3.7 # via # requests @@ -110,20 +117,18 @@ jmespath==1.0.1 # via # boto3 # botocore -kubi-ecs-logger==0.1.2 - # via django-log-formatter-ecs mail-parser==3.15.0 # via -r requirements.in markupsafe==2.1.2 # via werkzeug -marshmallow==3.19.0 - # via kubi-ecs-logger mohawk==1.1.0 # via -r requirements.in multidict==6.0.4 # via # aiohttp # yarl +nodeenv==1.8.0 + # via pre-commit notifications-python-client==9.1.0 # via -r requirements.in numpy==1.24.3 @@ -135,11 +140,14 @@ opensearch-py==2.6.0 # -r requirements.in # opensearch-dsl packaging==22.0 - # via # marshmallow # python-redis-rate-limit pandas==2.2.2 # via -r requirements.in +platformdirs==4.2.0 + # via virtualenv +pre-commit==3.7.0 + # via django-log-formatter-asim psycogreen==1.0.2 # via -r requirements.in psycopg2-binary==2.9.9 @@ -163,7 +171,9 @@ pytz==2022.7 # icalendar # pandas pyyaml==6.0.1 - # via -r requirements.in + # via + # -r requirements.in + # pre-commit redis==4.5.4 # via # django-redis @@ -220,6 +230,8 @@ urllib3==1.26.19 # opensearch-py # requests # sentry-sdk +virtualenv==20.25.1 + # via pre-commit werkzeug==3.0.3 # via -r requirements.in whitenoise==6.7.0