mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-08-09 14:34:53 +03:00
Implement suggested changes
This commit is contained in:
parent
b149c9933d
commit
3b8dd6e3c5
|
@ -5,6 +5,9 @@ import sentry_sdk
|
|||
|
||||
from sentry_sdk.integrations.django import DjangoIntegration
|
||||
from sentry_sdk.integrations.logging import LoggingIntegration
|
||||
{%- if cookiecutter.use_celery == 'y' %}
|
||||
from sentry_sdk.integrations.celery import CeleryIntegration
|
||||
{% endif %}
|
||||
|
||||
{% endif -%}
|
||||
from .base import * # noqa
|
||||
|
@ -275,7 +278,14 @@ sentry_logging = LoggingIntegration(
|
|||
event_level=None, # Send no events from log messages
|
||||
)
|
||||
|
||||
{%- if cookiecutter.use_celery == 'y' %}
|
||||
sentry_sdk.init(
|
||||
dsn=SENTRY_DSN,
|
||||
integrations=[sentry_logging, DjangoIntegration(), CeleryIntegration()],
|
||||
)
|
||||
{% else %}
|
||||
sentry_sdk.init(dsn=SENTRY_DSN, integrations=[sentry_logging, DjangoIntegration()])
|
||||
{% endif -%}
|
||||
{% endif %}
|
||||
# Your stuff...
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
|
@ -27,33 +27,6 @@ class CeleryAppConfig(AppConfig):
|
|||
def ready(self):
|
||||
installed_apps = [app_config.name for app_config in apps.get_app_configs()]
|
||||
app.autodiscover_tasks(lambda: installed_apps, force=True)
|
||||
{%- if cookiecutter.use_sentry == 'y' %}
|
||||
|
||||
if hasattr(settings, "SENTRY_DSN"):
|
||||
# Celery signal registration
|
||||
{% if cookiecutter.use_pycharm == 'y' -%}
|
||||
# Since Sentry is required in production only,
|
||||
# imports might (most surely will) be wiped out
|
||||
# during PyCharm code clean up started
|
||||
# in other environments.
|
||||
# @formatter:off
|
||||
{%- endif %}
|
||||
import sentry_sdk
|
||||
from sentry_sdk.integrations.celery import CeleryIntegration
|
||||
from sentry_sdk.integrations.logging import LoggingIntegration
|
||||
|
||||
{% if cookiecutter.use_pycharm == 'y' -%}
|
||||
# @formatter:on
|
||||
{%- endif %}
|
||||
sentry_logging = LoggingIntegration(
|
||||
level=settings.SENTRY_LOG_LEVEL, # Capture info and above as breadcrumbs
|
||||
event_level=None, # Send no events from log messages
|
||||
)
|
||||
sentry_sdk.init(
|
||||
dsn=settings.SENTRY_DSN,
|
||||
integrations=[sentry_logging, CeleryIntegration()],
|
||||
)
|
||||
{%- endif %}
|
||||
|
||||
|
||||
@app.task(bind=True)
|
||||
|
|
Loading…
Reference in New Issue
Block a user