Skip to content

Read the documented CELERY_TASK_NOTICE_LOG_LEVEL setting - #1058

Open
youdie006 wants to merge 1 commit into
jrobichaud:mainfrom
youdie006:celery-task-notice-log-level
Open

youdie006 wants to merge 1 commit into
jrobichaud:mainfrom
youdie006:celery-task-notice-log-level

Conversation

@youdie006

Copy link
Copy Markdown

docs/configuration.rst documents DJANGO_STRUCTLOG_CELERY_TASK_NOTICE_LOG_LEVEL for task_retrying and task_revoked, but AppSettings.CELERY_TASK_NOTICE_LOG_LEVEL reads DJANGO_STRUCTLOG_CELERY_TASK_RETRY_LOG_LEVEL, so the documented setting has no effect:

# settings: DJANGO_STRUCTLOG_CELERY_TASK_NOTICE_LOG_LEVEL = logging.ERROR
CeleryReceiver().receiver_task_retry(reason="boom")
# logged at WARNING, expected ERROR

This reads the documented name and falls back to the RETRY name, so anyone who already set that one keeps their level. Two rows in the same table name DJANGO_STRUCTLOG_DEFAULT_LOG_LEVEL and DJANGO_STRUCTLOG_START_LOG_LEVEL, while the code reads STATUS_DEFAULT_LOG_LEVEL and STATUS_START_LOG_LEVEL (as listed in #1024); those rows are corrected.

Tests added in test_app_settings.py (documented name, previous name, documented name winning) and test_receivers.py (the retry event at the configured level); they fail on main. The test_app suite passes apart from test_defer_task, which needs a Redis server I didn't run; ruff, black and isort pass.

Written with AI assistance (Claude); I have reviewed the change.

AppSettings.CELERY_TASK_NOTICE_LOG_LEVEL read
DJANGO_STRUCTLOG_CELERY_TASK_RETRY_LOG_LEVEL, so setting the documented
DJANGO_STRUCTLOG_CELERY_TASK_NOTICE_LOG_LEVEL had no effect on
task_retrying and task_revoked. Read the documented name first and keep
the previous one as a fallback. Also fix two configuration.rst rows that
named DEFAULT_LOG_LEVEL and START_LOG_LEVEL without the STATUS_ prefix
the code reads.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant