Django model for storing HttpRequest information.
Project description
# 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">
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django_request_logger_2-0.4.tar.gz
.
File metadata
- Download URL: django_request_logger_2-0.4.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.10 Darwin/23.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73bbe17a96a2a57c95a52673dd256ca3ee764dbec3e3be81f02c1b9d976ab1bf |
|
MD5 | 7a764060d2b8f2850d8e5f79eb449154 |
|
BLAKE2b-256 | 16929313d8e4d50999d34c0f20e9b433013cc1806b311a9e78ec6ac7585279cd |
File details
Details for the file django_request_logger_2-0.4-py3-none-any.whl
.
File metadata
- Download URL: django_request_logger_2-0.4-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.10 Darwin/23.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e882f418a4e088d5fda0e47b7f1c5d4e6e154eb808fb9eeec7a0571bf67541fc |
|
MD5 | fbb5ed89ed0c72a261ccfb6809225916 |
|
BLAKE2b-256 | facc3f8bcf2a10dff39ad316fab510ac36bcd11565a703a355bd976ac6a768ee |