Skip to content

feat: add logging for validation failures and misconfiguration#46

Merged
tdruez merged 3 commits intomainfrom
logging
Apr 21, 2026
Merged

feat: add logging for validation failures and misconfiguration#46
tdruez merged 3 commits intomainfrom
logging

Conversation

@tdruez
Copy link
Copy Markdown
Contributor

@tdruez tdruez commented Apr 21, 2026

New documentation from README:

## Logging

Django Altcha uses the standard Python `logging` module under the logger name
`django_altcha`. No logs are emitted under normal operation; logging fires only
on validation failures and misconfiguration.

### What gets logged

- **WARNING** on invalid or missing CAPTCHA tokens submitted to a form.
- **WARNING** on replay attempts (a challenge reused after it has already been validated).
- **ERROR** when `ALTCHA_HMAC_KEY` is not configured.
- **Exception with traceback** when verification or payload decoding raises
  unexpectedly.

Payloads, challenge values, and the HMAC key are never included in log
messages.

### Enabling logs

Add the `django_altcha` logger to your project's `LOGGING` setting:

LOGGING = {
    "version": 1,
    "disable_existing_loggers": False,
    "handlers": {
        "console": {
            "class": "logging.StreamHandler",
        },
    },
    "loggers": {
        "django_altcha": {
            "handlers": ["console"],
            "level": "WARNING",
        },
    },
}

Set `"level": "ERROR"` to see only misconfiguration and unexpected failures,
or `"level": "DEBUG"` to see additional diagnostic messages during development.

tdruez added 3 commits April 21, 2026 13:40
Signed-off-by: tdruez <tdruez@aboutcode.org>
Signed-off-by: tdruez <tdruez@aboutcode.org>
Signed-off-by: tdruez <tdruez@aboutcode.org>
@tdruez tdruez merged commit 63047cc into main Apr 21, 2026
8 checks passed
@tdruez tdruez deleted the logging branch April 21, 2026 09:53
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