Skip to content

Releases: vishalanandl177/DRF-API-Logger

Logging everything issue fixed

03 Apr 07:35
Compare
Choose a tag to compare

Logging everything issue fixed.
A new graph added to show the number of API calls by status code.

Migration file added

09 Mar 16:29
Compare
Choose a tag to compare

Migration file added and license changed to MIT.

No such file or directory: 'README.md' Bug Fixed

28 Feb 07:13
Compare
Choose a tag to compare

Improvements and model usage.

22 Feb 19:21
Compare
Choose a tag to compare

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)

18 Feb 21:49
Compare
Choose a tag to compare

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)

18 Feb 21:15
Compare
Choose a tag to compare

Showing count of per-day API calls in chart.

18 Feb 20:43
Compare
Choose a tag to compare
Merge branch 'master' of https://github.com/vishalanandl177/DRF-API-L…

…ogger

Fix error when response has no content-type

05 Jan 22:57
Compare
Choose a tag to compare
0.0.9

Fix error when response has no content-type

API URL max length increased from 256 to 512

21 Nov 11:16
Compare
Choose a tag to compare
0.0.8

API URL max length changed from 255 to 512

API with or without Host

12 Nov 17:16
Compare
Choose a tag to compare

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:

  1. ABSOLUTE (Default) :
    Function used request.build_absolute_uri()
    Output: http://127.0.0.1:8000/api/v1/?page=123

  2. FULL_PATH
    Function used request.get_full_path()
    Output: /api/v1/?page=123

  3. 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.