Skip to content

Commit

Permalink
feat: use celery structlog logging
Browse files Browse the repository at this point in the history
  • Loading branch information
adinhodovic committed May 31, 2024
1 parent b6d8f03 commit 0252942
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion config/celery_app.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import os
from logging.config import dictConfig
from pathlib import Path

from celery import Celery, bootsteps
from celery.schedules import crontab
from celery.signals import worker_ready, worker_shutdown
from celery.signals import setup_logging, worker_ready, worker_shutdown
from django.conf import settings

# set the default Django settings module for the 'celery' program.
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.production")
Expand All @@ -17,6 +19,11 @@
app.config_from_object("django.conf:settings", namespace="CELERY")


@setup_logging.connect
def config_loggers(*args, **kwargs):
dictConfig(settings.LOGGING)


HEARTBEAT_FILE = Path("/tmp/worker_heartbeat")
READINESS_FILE = Path("/tmp/worker_ready")

Expand Down
2 changes: 1 addition & 1 deletion config/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def filter(self, record):
return True


LOGGING["handlers"]["console"]["filters"] = [DevelopmentFilter()]
LOGGING["handlers"]["console"]["filters"] = [DevelopmentFilter()] # type: ignore

# Celery
# ------------------------------------------------------------------------------
Expand Down

0 comments on commit 0252942

Please sign in to comment.