Fixed #29329 -- Made datetime logging from runserver more consistent.

Setting default_msec_format=None will make it the same, unfortunately
it's not supported by Python, see https://bugs.python.org/issue40300.
This commit is contained in:
Hasan Ramezani 2020-04-01 18:46:46 +02:00 committed by Mariusz Felisiak
parent 96c6f9c61c
commit 7b31ba541f
2 changed files with 3 additions and 1 deletions

View File

@ -160,6 +160,8 @@ class RequireDebugTrue(logging.Filter):
class ServerFormatter(logging.Formatter):
default_time_format = '%d/%b/%Y %H:%M:%S'
def __init__(self, *args, **kwargs):
self.style = color_style()
super().__init__(*args, **kwargs)

View File

@ -605,4 +605,4 @@ class LogFormattersTests(SimpleTestCase):
with patch_django_server_logger() as logger_output:
logger.info(log_msg)
self.assertRegex(logger_output.getvalue(), r'^\[[-:,.\s\d]+\] %s' % log_msg)
self.assertRegex(logger_output.getvalue(), r'^\[[/:,\w\s\d]+\] %s\n' % log_msg)