Skip to content
Snippets Groups Projects
Commit a5e7d08c authored by dcz's avatar dcz
Browse files

Merge remote-tracking branch 'remotes/github/pre_freelu_horizontal_rel_bugfix'

parents 5e83adcb fdfdb39e
Branches
No related merge requests found
......@@ -82,6 +82,7 @@ MIDDLEWARE = [
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'syntax.middleware.SessionLogMiddleware',
'django.middleware.locale.LocaleMiddleware',
]
......
import json
import logging
import traceback
from django.http import Http404
from django.http.request import RawPostDataException
from django.utils.deprecation import MiddlewareMixin
# if you want to track it
# from sentry_sdk import capture_exception
class SessionLogMiddleware(MiddlewareMixin):
"""
this middleware to create a log
by current user
"""
def process_exception(self, request, exception):
try:
print("Exception, user-id={}, user-name={}, path={}, post={}, get={}".format(request.user.id, request.user.username, request.path, request.POST, request.GET))
except Exception as error:
print(error)
return # no return anything
def process_response(self, request, response):
print("user: id={}, name={}, path={}, post={}, get={}".format(request.user.id, request.user.username, request.path, request.POST, request.GET))
return response
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment