From cd3e2e24a0460d9e3336ab7971a72c224fca81b6 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Thu, 29 Jul 2021 23:15:02 +0100 Subject: [PATCH] Work around https://github.com/pypa/pip/pull/9450 (#60625) * Also pin the ``pip`` upgrade to be ``<21.2`` * Work around https://github.com/pypa/pip/pull/9450 See https://github.com/pypa/pip/issues/10212 Co-authored-by: Megan Wilhite Co-authored-by: Gareth J. Greenaway --- salt/__init__.py | 3 +++ salt/_logging/impl.py | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/salt/__init__.py b/salt/__init__.py index 3f372dab923b..01ed8446b372 100644 --- a/salt/__init__.py +++ b/salt/__init__.py @@ -119,3 +119,6 @@ def __define_global_system_encoding_variable__(): # This is now garbage collectable del __define_global_system_encoding_variable__ + +# Import Salt's logging machinery +import salt._logging.impl # isort:skip pylint: disable=unused-import diff --git a/salt/_logging/impl.py b/salt/_logging/impl.py index 1050165560db..cc39a2af16c2 100644 --- a/salt/_logging/impl.py +++ b/salt/_logging/impl.py @@ -385,11 +385,22 @@ def makeRecord( # Override the python's logging logger class as soon as this module is imported if logging.getLoggerClass() is not SaltLoggingClass: + # Import pip._internal which itself will install it's own custom logging handler + # we want to override that handler with ours + try: + import pip._internal.utils._log as pip_log_module # pylint: disable=no-name-in-module,import-error + except ImportError: + pip_log_module = None + logging.setLoggerClass(SaltLoggingClass) logging.addLevelName(QUIET, "QUIET") logging.addLevelName(PROFILE, "PROFILE") logging.addLevelName(TRACE, "TRACE") logging.addLevelName(GARBAGE, "GARBAGE") + if pip_log_module is not None: + # Let's make newer versions of pip work by patching SaltLoggingClass to + # add a verbose method which is what pip expects + SaltLoggingClass.verbose = SaltLoggingClass.debug # ----- REMOVE ON REFACTORING COMPLETE --------------------------------------------------------------------------> if not logging.root.handlers: