# Django Request Log
Simple Django model for logging HttpRequest instances.
## Why?
We have a number of libraries that store elements of a request (path,
querystring, user, response code, remote_addr, and so on), and it seemed
like time to create a single model that we can use in all of them,
storing a common set of values.
This is not a replacement for web server logs - it's a utility for use
in specific situations where you want to accurately log that someone
requested something.
## How it works
There is a single model, `RequestLog` and a model manager with a
`create` method that can take in a standard `HttpRequest` and / or
`HttpResponse` object and create a new `RequestLog` object. If you
are using this to record view functions, there is also a decorator,
`log_request` that will take care of all this for you:
```python
from request_logger.decorators import log_request
@log_request("downloads")
def download(request: HttpRequest) -> HttpReponse:
return HttpResponse("OK")
@log_request(lambda r: r.user.get_full_name())
def download(request: HttpRequest) -> HttpReponse:
return HttpResponse("OK")
```
The `log_request` argument is mandatory and is used as a "reference",
or category classifier. It can be a str, or a callable which takes
in the request as a single arg.
## Screenshots
**Admin list view**
<img src="screenshots/admin-list.png">
**Admin item view**
<img src="screenshots/admin-edit.png">
Raw data
{
"_id": null,
"home_page": "https://github.com/yunojuno/django-request-log",
"name": "django-request-logger-2",
"maintainer": "YunoJuno",
"docs_url": null,
"requires_python": ">=3.10,<4.0",
"maintainer_email": "code@yunojuno.com",
"keywords": "",
"author": "YunoJuno",
"author_email": "code@yunojuno.com",
"download_url": "https://files.pythonhosted.org/packages/16/92/9313d8e4d50999d34c0f20e9b433013cc1806b311a9e78ec6ac7585279cd/django_request_logger_2-0.4.tar.gz",
"platform": null,
"description": "# Django Request Log\n\nSimple Django model for logging HttpRequest instances.\n\n## Why?\n\nWe have a number of libraries that store elements of a request (path,\nquerystring, user, response code, remote_addr, and so on), and it seemed\nlike time to create a single model that we can use in all of them,\nstoring a common set of values.\n\nThis is not a replacement for web server logs - it's a utility for use\nin specific situations where you want to accurately log that someone\nrequested something.\n\n## How it works\n\nThere is a single model, `RequestLog` and a model manager with a\n`create` method that can take in a standard `HttpRequest` and / or\n`HttpResponse` object and create a new `RequestLog` object. If you\nare using this to record view functions, there is also a decorator,\n`log_request` that will take care of all this for you:\n\n```python\nfrom request_logger.decorators import log_request\n\n@log_request(\"downloads\")\ndef download(request: HttpRequest) -> HttpReponse:\n return HttpResponse(\"OK\")\n \n\n@log_request(lambda r: r.user.get_full_name())\ndef download(request: HttpRequest) -> HttpReponse:\n return HttpResponse(\"OK\")\n```\n\nThe `log_request` argument is mandatory and is used as a \"reference\",\nor category classifier. It can be a str, or a callable which takes\nin the request as a single arg.\n\n## Screenshots\n\n**Admin list view**\n\n<img src=\"screenshots/admin-list.png\">\n\n**Admin item view**\n\n<img src=\"screenshots/admin-edit.png\">\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Django model for storing HttpRequest information.",
"version": "0.4",
"project_urls": {
"Documentation": "https://github.com/yunojuno/django-request-log",
"Homepage": "https://github.com/yunojuno/django-request-log",
"Repository": "https://github.com/yunojuno/django-request-log"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "facc3f8bcf2a10dff39ad316fab510ac36bcd11565a703a355bd976ac6a768ee",
"md5": "fbb5ed89ed0c72a261ccfb6809225916",
"sha256": "e882f418a4e088d5fda0e47b7f1c5d4e6e154eb808fb9eeec7a0571bf67541fc"
},
"downloads": -1,
"filename": "django_request_logger_2-0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "fbb5ed89ed0c72a261ccfb6809225916",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10,<4.0",
"size": 11180,
"upload_time": "2023-11-15T09:11:51",
"upload_time_iso_8601": "2023-11-15T09:11:51.774249Z",
"url": "https://files.pythonhosted.org/packages/fa/cc/3f8bcf2a10dff39ad316fab510ac36bcd11565a703a355bd976ac6a768ee/django_request_logger_2-0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "16929313d8e4d50999d34c0f20e9b433013cc1806b311a9e78ec6ac7585279cd",
"md5": "7a764060d2b8f2850d8e5f79eb449154",
"sha256": "73bbe17a96a2a57c95a52673dd256ca3ee764dbec3e3be81f02c1b9d976ab1bf"
},
"downloads": -1,
"filename": "django_request_logger_2-0.4.tar.gz",
"has_sig": false,
"md5_digest": "7a764060d2b8f2850d8e5f79eb449154",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10,<4.0",
"size": 8424,
"upload_time": "2023-11-15T09:11:53",
"upload_time_iso_8601": "2023-11-15T09:11:53.461925Z",
"url": "https://files.pythonhosted.org/packages/16/92/9313d8e4d50999d34c0f20e9b433013cc1806b311a9e78ec6ac7585279cd/django_request_logger_2-0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-15 09:11:53",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "yunojuno",
"github_project": "django-request-log",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"tox": true,
"lcname": "django-request-logger-2"
}