From 7b31ba541f1dfb3a8e782b1319c25a24f9d86f8a Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Wed, 1 Apr 2020 18:46:46 +0200 Subject: [PATCH] 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. --- django/utils/log.py | 2 ++ tests/logging_tests/tests.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/django/utils/log.py b/django/utils/log.py index 717c15814cd..3d3e8701c7b 100644 --- a/django/utils/log.py +++ b/django/utils/log.py @@ -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) diff --git a/tests/logging_tests/tests.py b/tests/logging_tests/tests.py index 1967ca3687c..c2e26d5102e 100644 --- a/tests/logging_tests/tests.py +++ b/tests/logging_tests/tests.py @@ -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)