Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
93 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
""" JSON:API realization.""" | ||
__version = (0, 9, 0) | ||
__version = (0, 9, 1) | ||
|
||
__version__ = version = '.'.join(map(str, __version)) | ||
__project__ = PROJECT = __name__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
""" JSON-API signals.""" | ||
import django.dispatch | ||
|
||
signal_request = django.dispatch.Signal() | ||
signal_response = django.dispatch.Signal() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .signals import log_jsonapi_request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from django.dispatch import receiver | ||
from jsonapi.signals import ( | ||
signal_request as jsonapi_signal_request, | ||
signal_response as jsonapi_signal_response, | ||
) | ||
|
||
import logging | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
@receiver(jsonapi_signal_request) | ||
def log_jsonapi_request(sender, signal, request=None): | ||
msg = "{} {}".format(request.method, request.get_full_path()) | ||
msg = "{method} {path}".format( | ||
method=request.method, path=request.get_full_path()) | ||
logger.info(msg) | ||
|
||
|
||
@receiver(jsonapi_signal_response) | ||
def log_jsonapi_response(sender, signal, request=None, | ||
response=None, duration=None): | ||
msg = "{method} {path}".format( | ||
method=request.method, | ||
path=request.get_full_path() | ||
) | ||
if request.body: | ||
msg += " --data '{}'".format(request.body.decode('utf8')) | ||
|
||
msg += "; status={status_code} ({duration:.3f} sec)".format( | ||
duration=duration, | ||
status_code=response.status_code | ||
) | ||
logger.info(msg) |