logging: Use django.server to filter 200 and 304.

Previously, we were monkey patching the runserver command
in zerver/management/commands/rundjango.py for this.
This commit is contained in:
Umair Khan
2017-01-18 16:52:01 +05:00
committed by Tim Abbott
parent 85fbdd6b2d
commit ef0d2a4bb5
4 changed files with 20 additions and 17 deletions

View File

@@ -61,3 +61,13 @@ class RequireReallyDeployed(logging.Filter):
# type: (logging.LogRecord) -> bool
from django.conf import settings
return settings.PRODUCTION
def skip_200_and_304(record):
# type: (logging.LogRecord) -> bool
# Apparently, `status_code` is added by Django and is not an actual
# attribute of LogRecord; as a result, mypy throws an error if we
# access the `status_code` attribute directly.
if getattr(record, 'status_code') in [200, 304]:
return False
return True