Ignore permission denied and not found errors in the middleware logger.
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -2,12 +2,17 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from django.core.exceptions import PermissionDenied
|
||||||
|
from django.http import Http404
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class ErrorLoggingMiddleware(object):
|
class ErrorLoggingMiddleware(object):
|
||||||
def process_exception(self, request, exception):
|
def process_exception(self, request, exception):
|
||||||
logger.exception(
|
if not isinstance(exception, (PermissionDenied, Http404)):
|
||||||
'Exception caught by request middleware; %s, %s', request,
|
# Don't log non critical exceptions
|
||||||
exception
|
logger.exception(
|
||||||
)
|
'Exception caught by request middleware; %s, %s', request,
|
||||||
|
exception
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user