Releases: vishalanandl177/DRF-API-Logger
Hide Sensitive Data From Logs and Change default database to store API logs
You may wish to hide sensitive information from being exposed in the logs.
You do this by setting DRF_API_LOGGER_EXCLUDE_KEYS
in settings.py to a list of your desired sensitive keys.
The default is
DRF_API_LOGGER_EXCLUDE_KEYS = ['password', 'token', 'access', 'refresh']
Sensitive data will be replaced with "FILTERED".
You can specify the database where to store DRF API Logger logs by specifying DRF_API_LOGGER_DEFAULT_DATABASE
.
DRF_API_LOGGER_DEFAULT_DATABASE = 'default' # Default to "default" if not specified
Make sure to migrate the database specified in DRF_API_LOGGER_DEFAULT_DATABASE.
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.
1.0.0 Merge branch 'master' of https://github.com/vishalanandl177/DRF-API-L…
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