mirror of https://github.com/zulip/zulip.git
Wrap Django runserver to prevent spammy logging.
Django's `manage.py runserver` prints a relatively low-information log line for every request of the form: [14/Dec/2015 00:43:06]"GET /static/js/message_list.js HTTP/1.0" 200 21969 This is pretty spammy, especially given that we already have our own middleware printing a more detailed version of the same log lines: 2015-12-14 00:43:06,935 INFO 127.0.0.1 GET 200 0ms /static/js/message_list.js (unauth via ?) Since runserver doesn't have support controlling whether these log lines are printed, we wrap it with a small bit of code that silences the log lines for 200/304 requests (aka the uninteresting ones).
This commit is contained in:
parent
be9939b2ad
commit
dfaf45b2b6
|
@ -77,7 +77,7 @@ os.setpgrp()
|
|||
# zulip/urls.py.
|
||||
cmds = [['./tools/compile-handlebars-templates', 'forever'],
|
||||
['./tools/webpack', 'watch'],
|
||||
['python', 'manage.py', 'runserver', '--nostatic'] +
|
||||
['python', 'manage.py', 'rundjango'] +
|
||||
manage_args + ['localhost:%d' % (django_port,)],
|
||||
['python', 'manage.py', 'runtornado'] +
|
||||
manage_args + ['localhost:%d' % (tornado_port,)],
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
# Wrapper around Django's runserver to allow filtering logs.
|
||||
|
||||
from django.core.servers.basehttp import WSGIRequestHandler
|
||||
orig_log_message = WSGIRequestHandler.log_message
|
||||
def log_message_monkey(self, format, *args):
|
||||
# Filter output for 200 or 304 responses.
|
||||
if args[1] == '200' or args[1] == '304':
|
||||
return
|
||||
return orig_log_message(self, format, *args)
|
||||
|
||||
WSGIRequestHandler.log_message = log_message_monkey
|
||||
|
||||
from django.core.management.commands.runserver import Command
|
Loading…
Reference in New Issue