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:
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
Admin item view
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
Hashes for django-request-logger-2-0.3.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5f8848e7374e06a6f70f8b2d16d1b79fc5d6cb2ef296edd76740b89fab7f334 |
|
MD5 | 5d56bef540e06490b3217d8a7ba5c0b3 |
|
BLAKE2b-256 | 238444d4cdb1c44414da43eb8fb3146b9dc5bd21924cb2f1fd03eb1a10426d1e |
Hashes for django_request_logger_2-0.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eedd5972bd8878e69aff7682209fe99c2eeb303cf85687291f8c61642089e632 |
|
MD5 | 33db5945de96939bf602ad9aace93822 |
|
BLAKE2b-256 | 1a84d44e422bf1fa9ec43fb31f0b0574fce9a8f0006ad35105f1e5529e374a7a |