diff --git a/django/core/management/commands/runserver.py b/django/core/management/commands/runserver.py
index 0ca15fd..2234520 100644
a
|
b
|
class Command(BaseCommand):
|
26 | 26 | help='Tells Django to NOT use threading.'), |
27 | 27 | make_option('--noreload', action='store_false', dest='use_reloader', default=True, |
28 | 28 | help='Tells Django to NOT use the auto-reloader.'), |
| 29 | make_option('--verbose-logging', action='store_true', dest='verbose_logging', default=False, |
| 30 | help='Tells Django to log all requests including those to admin media files and /favicon.ico'), |
29 | 31 | ) |
30 | 32 | help = "Starts a lightweight Web server for development." |
31 | 33 | args = '[optional port number, or ipaddr:port]' |
… |
… |
class Command(BaseCommand):
|
111 | 113 | try: |
112 | 114 | handler = self.get_handler(*args, **options) |
113 | 115 | run(self.addr, int(self.port), handler, |
114 | | ipv6=self.use_ipv6, threading=threading) |
| 116 | ipv6=self.use_ipv6, threading=threading, |
| 117 | verbose_logging=options.get('verbose_logging', False)) |
115 | 118 | except WSGIServerException as e: |
116 | 119 | # Use helpful error messages instead of ugly tracebacks. |
117 | 120 | ERRORS = { |
diff --git a/django/core/servers/basehttp.py b/django/core/servers/basehttp.py
index 89ec2b3..5db55ef 100644
a
|
b
|
class WSGIServer(simple_server.WSGIServer, object):
|
126 | 126 | |
127 | 127 | |
128 | 128 | class WSGIRequestHandler(simple_server.WSGIRequestHandler, object): |
| 129 | verbose_logging = False |
129 | 130 | |
130 | 131 | def __init__(self, *args, **kwargs): |
131 | 132 | from django.conf import settings |
… |
… |
class WSGIRequestHandler(simple_server.WSGIRequestHandler, object):
|
142 | 143 | |
143 | 144 | def log_message(self, format, *args): |
144 | 145 | # Don't bother logging requests for admin images or the favicon. |
145 | | if (self.path.startswith(self.admin_static_prefix) |
146 | | or self.path == '/favicon.ico'): |
| 146 | if not self.verbose_logging and ( |
| 147 | (self.path.startswith(self.admin_static_prefix) |
| 148 | or self.path == '/favicon.ico')): |
147 | 149 | return |
148 | 150 | |
149 | 151 | msg = "[%s] %s\n" % (self.log_date_time_string(), format % args) |
… |
… |
class WSGIRequestHandler(simple_server.WSGIRequestHandler, object):
|
169 | 171 | sys.stderr.write(msg) |
170 | 172 | |
171 | 173 | |
172 | | def run(addr, port, wsgi_handler, ipv6=False, threading=False): |
| 174 | def get_request_handler(**options): |
| 175 | handler_cls = WSGIRequestHandler |
| 176 | if not options.get('verbose_logging', False): |
| 177 | return handler_cls |
| 178 | return type(str('WSGIRequestHandler'), (handler_cls,), options) |
| 179 | |
| 180 | |
| 181 | def run(addr, port, wsgi_handler, ipv6=False, threading=False, |
| 182 | verbose_logging=False): |
173 | 183 | server_address = (addr, port) |
174 | 184 | if threading: |
175 | 185 | httpd_cls = type(str('WSGIServer'), (socketserver.ThreadingMixIn, WSGIServer), {}) |
176 | 186 | else: |
177 | 187 | httpd_cls = WSGIServer |
178 | | httpd = httpd_cls(server_address, WSGIRequestHandler, ipv6=ipv6) |
| 188 | httpd = httpd_cls(server_address, |
| 189 | get_request_handler(verbose_logging=verbose_logging), |
| 190 | ipv6=ipv6) |
179 | 191 | httpd.set_app(wsgi_handler) |
180 | 192 | httpd.serve_forever() |