From b849dbcb4fdf0356ae3e2a1d886acaee0dc3a7c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Cant=C3=B9?= Date: Tue, 26 Mar 2024 11:59:33 +0100 Subject: [PATCH] separate settings --- src/urban/custom_settings.py | 48 ++++++++++++++++++++++++++++++++++++ src/urban/settings.py | 46 ---------------------------------- 2 files changed, 48 insertions(+), 46 deletions(-) create mode 100644 src/urban/custom_settings.py diff --git a/src/urban/custom_settings.py b/src/urban/custom_settings.py new file mode 100644 index 0000000..857d438 --- /dev/null +++ b/src/urban/custom_settings.py @@ -0,0 +1,48 @@ +import os + +from urban.lsettings import * + +INSTALLED_APPS += ( + 'django_media_fixtures', +) + + +SENTRY_DSN = os.getenv("SENTRY_DSN", None) +if SENTRY_DSN: + import logging + import sentry_sdk + from sentry_sdk.integrations.django import DjangoIntegration + from sentry_sdk.integrations.logging import LoggingIntegration + from sentry_sdk.integrations.redis import RedisIntegration + from sentry_sdk.integrations.celery import CeleryIntegration + + SENTRY_LOG_LEVEL = int(os.getenv("DJANGO_SENTRY_LOG_LEVEL", logging.INFO)) + + sentry_logging = LoggingIntegration( + level=SENTRY_LOG_LEVEL, # Capture info and above as breadcrumbs + event_level=logging.ERROR, # Send errors as events + ) + + integrations = [sentry_logging, DjangoIntegration(), RedisIntegration(), CeleryIntegration()] + + sentry_sdk.init( + dsn=SENTRY_DSN, + integrations=integrations, + environment=os.getenv("SENTRY_ENVIRONMENT", "production"), + traces_sample_rate=float(os.getenv("SENTRY_TRACES_SAMPLE_RATE", 0.1)), + ) + + LOGGING["loggers"] = { + "django.db.backends": { + "level": "ERROR", + "handlers": ["console"], + "propagate": False, + }, + # Errors logged by the SDK itself + "sentry_sdk": {"level": "ERROR", "handlers": ["console"], "propagate": False}, + "django.security.DisallowedHost": { + "level": "ERROR", + "handlers": ["console"], + "propagate": False, + }, + } diff --git a/src/urban/settings.py b/src/urban/settings.py index 0c8dbc5..1c448bf 100644 --- a/src/urban/settings.py +++ b/src/urban/settings.py @@ -162,49 +162,3 @@ # Add your specific LDAP configuration after this comment: # https://docs.geonode.org/en/master/advanced/contrib/#configuration - - -INSTALLED_APPS += ( - 'django_media_fixtures', -) - - -SENTRY_DSN = os.getenv("SENTRY_DSN", None) -if SENTRY_DSN: - import logging - import sentry_sdk - from sentry_sdk.integrations.django import DjangoIntegration - from sentry_sdk.integrations.logging import LoggingIntegration - from sentry_sdk.integrations.redis import RedisIntegration - from sentry_sdk.integrations.celery import CeleryIntegration - - SENTRY_LOG_LEVEL = int(os.getenv("DJANGO_SENTRY_LOG_LEVEL", logging.INFO)) - - sentry_logging = LoggingIntegration( - level=SENTRY_LOG_LEVEL, # Capture info and above as breadcrumbs - event_level=logging.ERROR, # Send errors as events - ) - - integrations = [sentry_logging, DjangoIntegration(), RedisIntegration(), CeleryIntegration()] - - sentry_sdk.init( - dsn=SENTRY_DSN, - integrations=integrations, - environment=os.getenv("SENTRY_ENVIRONMENT", "production"), - traces_sample_rate=float(os.getenv("SENTRY_TRACES_SAMPLE_RATE", 0.1)), - ) - - LOGGING["loggers"] = { - "django.db.backends": { - "level": "ERROR", - "handlers": ["console"], - "propagate": False, - }, - # Errors logged by the SDK itself - "sentry_sdk": {"level": "ERROR", "handlers": ["console"], "propagate": False}, - "django.security.DisallowedHost": { - "level": "ERROR", - "handlers": ["console"], - "propagate": False, - }, - }