{"id":36823145,"url":"https://github.com/axieum/django-user-trace","last_synced_at":"2026-01-12T14:02:11.633Z","repository":{"id":148378404,"uuid":"620068726","full_name":"axieum/django-user-trace","owner":"axieum","description":"🙋‍♂️ A Python logging filter for Django user attributes","archived":false,"fork":false,"pushed_at":"2025-12-14T07:08:34.000Z","size":1363,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-16T06:01:46.410Z","etag":null,"topics":["async","django","hacktoberfest","logging","logs","middleware","sync","trace","tracing","user","web"],"latest_commit_sha":null,"homepage":"https://axieum.github.io/django-user-trace/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/axieum.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-03-28T01:01:35.000Z","updated_at":"2025-12-14T07:07:12.000Z","dependencies_parsed_at":"2023-12-07T10:46:32.969Z","dependency_job_id":null,"html_url":"https://github.com/axieum/django-user-trace","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/axieum/django-user-trace","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axieum%2Fdjango-user-trace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axieum%2Fdjango-user-trace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axieum%2Fdjango-user-trace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axieum%2Fdjango-user-trace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/axieum","download_url":"https://codeload.github.com/axieum/django-user-trace/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axieum%2Fdjango-user-trace/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28340224,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T12:22:26.515Z","status":"ssl_error","status_checked_at":"2026-01-12T12:22:10.856Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","django","hacktoberfest","logging","logs","middleware","sync","trace","tracing","user","web"],"created_at":"2026-01-12T14:02:10.950Z","updated_at":"2026-01-12T14:02:11.595Z","avatar_url":"https://github.com/axieum.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# `django-user-trace`\n\nA Python [logging][python:logging] filter for [Django][django] user attributes\n\n[![Build](https://img.shields.io/github/actions/workflow/status/axieum/django-user-trace/release.yml?branch=main\u0026style=flat-square)][ci:release]\n[![Coverage](https://img.shields.io/codecov/c/github/axieum/django-user-trace?style=flat-square)][codecov]\n[![Python](https://img.shields.io/pypi/pyversions/django-user-trace?style=flat-square)][python]\n[![PyPI](https://img.shields.io/pypi/v/django-user-trace?style=flat-square\u0026include_prereleases\u0026sort=semver)][pypi]\n\n\u003c/div\u003e\n\n`django-user-trace` provides a Python [logging][python:logging] filter that\ninjects attributes from the currently logged in [Django][django] user.\n\n```\nINFO ... john_doe project.views This is a view log, and should have a user.\nINFO ... mike_scott project.views This is a view log, and should have a user.\nWARNING ... john_doe project.services.file Some warning in a function!\n```\n\nIt uses a [`ContextVar`][python:contextvars] to store user attributes for use on\nthe current thread. These are then injected into all log records via a logging\nfilter.\n\n_[Visit the documentation][docs]._\n\n```mermaid\nsequenceDiagram\n    actor User\n    User -\u003e\u003e+ django: make request\n    django -\u003e\u003e+ django.contrib.auth: AuthenticationMiddleware\n    django.contrib.auth -\u003e\u003e+ django: set `request.user`\n    django -\u003e\u003e+ django_user_trace: django_user_trace_middleware\n    note over django, django_user_trace: Capture relevant user attributes into a `ContextVar`\n    django_user_trace -\u003e\u003e+ django: continue\n    django --\u003e logging: log message\n    logging -\u003e\u003e+ django_user_trace: get user attrs\n    django_user_trace --\u003e\u003e logging: `ContextVar` for user attrs\n    django -\u003e\u003e+ django_user_trace: signal `request_finished`\n    note over django, django_user_trace: Clear user attributes from the `ContextVar`\n    django_user_trace -\u003e\u003e+ django: continue\n    django --\u003e\u003e User: send response\n```\n\n#### Supports\n\n* [Celery task logging][celery]\n\n#### Resources\n\n* [Django \u0026mdash; How to configure and use logging][django:logging]\n\n#### Related Projects\n\n* [madzak/python-json-logger][python-json-logger]\n* [snok/asgi-correlation-id][asgi-correlation-id]\n* [snok/django-guid][django-guid]\n\n## Installation\n\nInstall via `pip`:\n\n```shell\npip install django-user-trace\n```\n\nOr, via [`poetry`][poetry]:\n\n```shell\npoetry add django-user-trace\n```\n\n## Contributing\n\nThank you for considering contributing to `django-user-trace`! Please see the\n[Contribution Guidelines][contributing].\n\n## Security Vulnerabilities\n\nPlease review the [Security Policy][security] on how to report security\nvulnerabilities.\n\n## Licence\n\n`django-user-trace` is open-sourced software licenced under the\n[MIT licence][licence].\n\n[asgi-correlation-id]: https://github.com/snok/asgi-correlation-id\n[celery]: https://docs.celeryq.dev/\n[ci:release]: https://github.com/axieum/django-user-trace/actions/workflows/release.yml\n[ci:test]: https://github.com/axieum/django-user-trace/actions/workflows/test.yml\n[codecov]: https://app.codecov.io/gh/axieum/django-user-trace\n[contributing]: CONTRIBUTING.md\n[django]: https://djangoproject.com/\n[django:logging]: https://docs.djangoproject.com/en/stable/howto/logging/\n[django-guid]: https://github.com/snok/django-guid\n[docs]: https://axieum.github.io/django-user-trace\n[licence]: https://opensource.org/licenses/MIT\n[poetry]: https://python-poetry.org/\n[pypi]: https://pypi.org/project/django-user-trace\n[python]: https://python.org/\n[python:contextvars]: https://docs.python.org/3/library/contextvars.html\n[python:logging]: https://docs.python.org/3/library/logging.html\n[python-json-logger]: https://github.com/madzak/python-json-logger\n[security]: SECURITY.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxieum%2Fdjango-user-trace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faxieum%2Fdjango-user-trace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxieum%2Fdjango-user-trace/lists"}