Releases: vishalanandl177/DRF-API-Logger
Logging everything issue fixed
Logging everything issue fixed.
A new graph added to show the number of API calls by status code.
Migration file added
Migration file added and license changed to MIT.
No such file or directory: 'README.md' Bug Fixed
1.0.4 BUILD removed
Improvements and model usage.
You can use the DRF API Logger Model to query some information.
Note: Make sure to set "DRF_API_LOGGER_DATABASE = True" in the settings.py file.
from drf_api_logger.models import APILogsModel
"""
Example:
Select records for status_code 200.
"""
result_for_200_status_code = APILogsModel.objects.filter(status_code=200)
Model:
class APILogsModel(Model):
id = models.BigAutoField(primary_key=True)
api = models.CharField(max_length=512, help_text='API URL')
headers = models.TextField()
body = models.TextField()
method = models.CharField(max_length=10, db_index=True)
client_ip_address = models.CharField(max_length=50)
response = models.TextField()
status_code = models.PositiveSmallIntegerField(help_text='Response status code', db_index=True)
execution_time = models.DecimalField(decimal_places=5, max_digits=8,
help_text='Server execution time (Not complete response time.)')
added_on = models.DateTimeField()
Showing count of per-day API calls in chart. (Rebuilding)
Make sure to add the code below in settings.py
'DIRS': [os.path.join(BASE_DIR, 'templates')],
The final code should look like this.
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
Showing count of per-day API calls in chart. (Rebuilding)
1.0.1 Rebuilding
Showing count of per-day API calls in chart.
Merge branch 'master' of https://github.com/vishalanandl177/DRF-API-L… …ogger
Fix error when response has no content-type
0.0.9 Fix error when response has no content-type
API URL max length increased from 256 to 512
0.0.8 API URL max length changed from 255 to 512
API with or without Host
You can specify the endpoint of API should have an absolute URI or not by setting this variable in DRF settings.py file.
Set DRF_API_LOGGER_PATH_TYPE = 'ABSOLUTE' in settings.py
Possible values are ABSOLUTE, FULL_PATH, or RAW_URI.
Considering we are accessing the following URL: http://127.0.0.1:8000/api/v1/?page=123
DRF_API_LOGGER_PATH_TYPE possible values are:
-
ABSOLUTE (Default) :
Function used request.build_absolute_uri()
Output: http://127.0.0.1:8000/api/v1/?page=123 -
FULL_PATH
Function used request.get_full_path()
Output: /api/v1/?page=123 -
RAW_URI
Function used request.get_raw_uri()
Output: http://127.0.0.1:8000/api/v1/?page=123
Note: Similar to ABSOLUTE but skip allowed hosts protection, so may return insecure URI.