diff --git a/django/core/servers/basehttp.py b/django/core/servers/basehttp.py index 1efa4bb915..4e2f8dd863 100644 --- a/django/core/servers/basehttp.py +++ b/django/core/servers/basehttp.py @@ -104,7 +104,7 @@ class WSGIRequestHandler(simple_server.WSGIRequestHandler, object): def log_message(self, format, *args): - msg = "[%s]" % self.log_date_time_string() + msg = "[%s] " % self.log_date_time_string() try: msg += "%s\n" % (format % args) except UnicodeDecodeError: diff --git a/tests/servers/test_basehttp.py b/tests/servers/test_basehttp.py index b9008be8e8..4a3ba3577e 100644 --- a/tests/servers/test_basehttp.py +++ b/tests/servers/test_basehttp.py @@ -13,6 +13,16 @@ class Stub(object): class WSGIRequestHandlerTestCase(SimpleTestCase): + + def test_log_message(self): + request = WSGIRequest(RequestFactory().get('/').environ) + request.makefile = lambda *args, **kwargs: BytesIO() + handler = WSGIRequestHandler(request, '192.168.0.2', None) + + with captured_stderr() as stderr: + handler.log_message('GET %s %s', 'A', 'B') + self.assertIn('] GET A B', stderr.getvalue()) + def test_https(self): request = WSGIRequest(RequestFactory().get('/').environ) request.makefile = lambda *args, **kwargs: BytesIO()