Log everything from your DRF view
Project description
Django REST API Logger
Mixin which logs all needed data from API
Just import APILoggingMixin
and put it in first base class of your API and it'll do the rest
Requirements
- Django
Installation
The package is available on PyPI:
pip install django-rest-api-logger
How to use
IMPORTANT: Don't forget to put it in the first base class
class ProductListAPI(APILoggingMixin, OtherMixinsOrClass):
...
Modes
Put these variables in your django settings file
-
Native Logger
# file ------> Writes logs to file # console ---> Prints logs in console DRF_LOGGER_HANDLER = ["file", "console"] # Log file directory # Make sure directory exists DRF_LOGGER_FILE = "/tmp/custom_logger.log"
-
Elasticsearch
DRF_LOGGER_ELASTICSEARCH_ENABLED = True # Elasticsearch Hosts DRF_LOGGER_ELASTICSEARCH_HOSTS = ["localhost:9200"] # Elasticsearch Index DRF_LOGGER_ELASTICSEARCH_INDEX = "django_rest_api_logger" # Elasticsearch Auth DRF_LOGGER_ELASTICSEARCH_AUTH = ('user', 'secret') # Or None # Elasticsearch SSL DRF_LOGGER_ELASTICSEARCH_SSL = False
-
Mongo Log
# Mongo Host DRF_LOGGER_MONGO_HOST = "mongodb://username:password@localhost:27017/" # Mongo Attempting Connection Timeout: DRF_LOGGER_MONGO_TIMEOUT_MS = 10 # Log db DRF_LOGGER_MONGO_LOG_DB = "log" # Log collection DRF_LOGGER_MONGO_LOG_COLLECTION = "logs"
-
Custom
# If DRF_LOGGER_CUSTOM_HANDLER is set to false then aboves modes won't work # You have to override `handle_log` function in order to implement your own handler DRF_LOGGER_CUSTOM_HANDLER = False
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for django_rest_api_logger-0.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 692532322e79a3e1070fc06bccbf12bb0e0b395cc09e110f04b9e09f55dddf6f |
|
MD5 | 7972935c74dc9ebeac63dfcf86c21f17 |
|
BLAKE2b-256 | 49f285132dbedc2d3ffed29bf9e47facd847efa713ef5b195ecc65ae66b060df |