mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-07-11 08:32:21 +03:00
Fix logging configuration for Celery tasks (#5563)
This commit is contained in:
parent
df2bd97a24
commit
411e92cf9d
|
@ -1,6 +1,7 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from celery import Celery
|
from celery import Celery
|
||||||
|
from celery.signals import setup_logging
|
||||||
|
|
||||||
# set the default Django settings module for the 'celery' program.
|
# set the default Django settings module for the 'celery' program.
|
||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local")
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local")
|
||||||
|
@ -13,5 +14,15 @@ app = Celery("{{cookiecutter.project_slug}}")
|
||||||
# should have a `CELERY_` prefix.
|
# should have a `CELERY_` prefix.
|
||||||
app.config_from_object("django.conf:settings", namespace="CELERY")
|
app.config_from_object("django.conf:settings", namespace="CELERY")
|
||||||
|
|
||||||
|
|
||||||
|
@setup_logging.connect
|
||||||
|
def config_loggers(*args, **kwargs):
|
||||||
|
from logging.config import dictConfig
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
dictConfig(settings.LOGGING)
|
||||||
|
|
||||||
|
|
||||||
# Load task modules from all registered Django app configs.
|
# Load task modules from all registered Django app configs.
|
||||||
app.autodiscover_tasks()
|
app.autodiscover_tasks()
|
||||||
|
|
|
@ -327,6 +327,8 @@ CELERY_BEAT_SCHEDULER = "django_celery_beat.schedulers:DatabaseScheduler"
|
||||||
CELERY_WORKER_SEND_TASK_EVENTS = True
|
CELERY_WORKER_SEND_TASK_EVENTS = True
|
||||||
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#std-setting-task_send_sent_event
|
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#std-setting-task_send_sent_event
|
||||||
CELERY_TASK_SEND_SENT_EVENT = True
|
CELERY_TASK_SEND_SENT_EVENT = True
|
||||||
|
# https://cheat.readthedocs.io/en/latest/django/celery.html
|
||||||
|
CELERYD_HIJACK_ROOT_LOGGER = False
|
||||||
|
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
# django-allauth
|
# django-allauth
|
||||||
|
|
Loading…
Reference in New Issue
Block a user