Skip to content

Commit

Permalink
1. Changed request.path to request.path_info in middleware.
Browse files Browse the repository at this point in the history
2. Deprecation warning for thread setName or getName.
3. Request twice when method not in DRF_API_LOGGER_METHODS.
4. Unicode Escape problem in headers, body and responses.
  • Loading branch information
vishalanandl177 committed Sep 17, 2022
1 parent 94ff0f1 commit 74bbecb
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# DRF API Logger
![version](https://img.shields.io/badge/version-1.1.10-blue.svg)
![version](https://img.shields.io/badge/version-1.1.11-blue.svg)
[![Downloads](https://static.pepy.tech/personalized-badge/drf-api-logger?period=total&units=none&left_color=black&right_color=orange&left_text=Downloads%20Total)](http://pepy.tech/project/drf-api-logger)
[![Downloads](https://static.pepy.tech/personalized-badge/drf-api-logger?period=month&units=none&left_color=black&right_color=orange&left_text=Downloads%20Last%20Month)](https://pepy.tech/project/drf-api-logger)
[![Downloads](https://static.pepy.tech/personalized-badge/drf-api-logger?period=week&units=none&left_color=black&right_color=orange&left_text=Downloads%20Last%20Week)](https://pepy.tech/project/drf-api-logger)
Expand Down
7 changes: 3 additions & 4 deletions drf_api_logger/middleware/api_logger_middleware.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import json
import time
import bleach
from django.conf import settings
from django.urls import resolve
from django.utils import timezone
Expand Down Expand Up @@ -62,8 +61,8 @@ def __call__(self, request):
# Run only if logger is enabled.
if self.DRF_API_LOGGER_DATABASE or self.DRF_API_LOGGER_SIGNAL:

url_name = resolve(request.path).url_name
namespace = resolve(request.path).namespace
url_name = resolve(request.path_info).url_name
namespace = resolve(request.path_info).namespace

# Always skip Admin panel
if namespace == 'admin':
Expand Down Expand Up @@ -100,7 +99,7 @@ def __call__(self, request):

# Log only registered methods if available.
if len(self.DRF_API_LOGGER_METHODS) > 0 and method not in self.DRF_API_LOGGER_METHODS:
return self.get_response(request)
return response

if response.get('content-type') in ('application/json', 'application/vnd.api+json',):
if getattr(response, 'streaming', False):
Expand Down
5 changes: 3 additions & 2 deletions drf_api_logger/start_logger_when_server_starts.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
already_exists = False

for t in threading.enumerate():
if t.getName() == LOG_THREAD_NAME:
if t.name == LOG_THREAD_NAME:
already_exists = True
break

if not already_exists:
t = InsertLogIntoDatabase()
t.daemon = True
t.setName(LOG_THREAD_NAME)
t.name = LOG_THREAD_NAME
t.start()
LOGGER_THREAD = t
Binary file modified requirements.txt
Binary file not shown.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def get_long_desc():

setuptools.setup(
name="drf_api_logger",
version="1.1.10",
version="1.1.11",
author="Vishal Anand",
author_email="vishalanandl177@gmail.com",
description="An API Logger for your Django Rest Framework project.",
Expand Down

0 comments on commit 74bbecb

Please sign in to comment.