From b92c0c1112483b9edc48e9cb1ffb121eba887e75 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sun, 27 Dec 2020 13:29:40 +0200 Subject: [PATCH] Use Formatter.default_time_format after dropping PY2 --- news/80B9D718-3054-41C7-B920-78348DFD01A6.trivial.rst | 0 src/pip/_internal/utils/logging.py | 5 ++--- 2 files changed, 2 insertions(+), 3 deletions(-) create mode 100644 news/80B9D718-3054-41C7-B920-78348DFD01A6.trivial.rst diff --git a/news/80B9D718-3054-41C7-B920-78348DFD01A6.trivial.rst b/news/80B9D718-3054-41C7-B920-78348DFD01A6.trivial.rst new file mode 100644 index 000000000..e69de29bb diff --git a/src/pip/_internal/utils/logging.py b/src/pip/_internal/utils/logging.py index 9fd1d42c7..dabc98180 100644 --- a/src/pip/_internal/utils/logging.py +++ b/src/pip/_internal/utils/logging.py @@ -101,6 +101,7 @@ def get_indentation(): class IndentingFormatter(logging.Formatter): + default_time_format = "%Y-%m-%dT%H:%M:%S" def __init__(self, *args, **kwargs): """ @@ -139,9 +140,7 @@ class IndentingFormatter(logging.Formatter): prefix = '' if self.add_timestamp: - # TODO: Use Formatter.default_time_format after dropping PY2. - t = self.formatTime(record, "%Y-%m-%dT%H:%M:%S") - prefix = '{t},{record.msecs:03.0f} '.format(**locals()) + prefix = f"{self.formatTime(record)} " prefix += " " * get_indentation() formatted = "".join([ prefix + line