Skip to content

Commit

Permalink
separate settings
Browse files Browse the repository at this point in the history
  • Loading branch information
nicokant committed Mar 26, 2024
1 parent e9ea91c commit b849dbc
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 46 deletions.
48 changes: 48 additions & 0 deletions src/urban/custom_settings.py
Original file line number Diff line number Diff line change
@@ -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,
},
}
46 changes: 0 additions & 46 deletions src/urban/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}

0 comments on commit b849dbc

Please sign in to comment.