mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-03-31 15:04:14 +03:00
Fix logging configuration for Celery tasks (#5563)
This commit is contained in:
parent
df2bd97a24
commit
411e92cf9d
|
@ -1,6 +1,7 @@
|
|||
import os
|
||||
|
||||
from celery import Celery
|
||||
from celery.signals import setup_logging
|
||||
|
||||
# set the default Django settings module for the 'celery' program.
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local")
|
||||
|
@ -13,5 +14,15 @@ app = Celery("{{cookiecutter.project_slug}}")
|
|||
# should have a `CELERY_` prefix.
|
||||
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.
|
||||
app.autodiscover_tasks()
|
||||
|
|
|
@ -327,6 +327,8 @@ CELERY_BEAT_SCHEDULER = "django_celery_beat.schedulers:DatabaseScheduler"
|
|||
CELERY_WORKER_SEND_TASK_EVENTS = True
|
||||
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#std-setting-task_send_sent_event
|
||||
CELERY_TASK_SEND_SENT_EVENT = True
|
||||
# https://cheat.readthedocs.io/en/latest/django/celery.html
|
||||
CELERYD_HIJACK_ROOT_LOGGER = False
|
||||
|
||||
{%- endif %}
|
||||
# django-allauth
|
||||
|
|
Loading…
Reference in New Issue
Block a user