diff --git a/news/9447.feature.rst b/news/9447.feature.rst new file mode 100644 index 00000000000..4be3fb71bd5 --- /dev/null +++ b/news/9447.feature.rst @@ -0,0 +1 @@ +Require ``-vv`` for full debug-level output, ``-v`` now only enables showing subprocess output, e.g. of ``setup.py install``. diff --git a/src/pip/_internal/utils/logging.py b/src/pip/_internal/utils/logging.py index 687bfe3b2f6..bdfeb3ba173 100644 --- a/src/pip/_internal/utils/logging.py +++ b/src/pip/_internal/utils/logging.py @@ -246,7 +246,7 @@ def setup_logging(verbosity, no_color, user_log_file): """ # Determine the level to be logging at. - if verbosity >= 1: + if verbosity >= 2: level = "DEBUG" elif verbosity == -1: level = "WARNING" @@ -257,6 +257,14 @@ def setup_logging(verbosity, no_color, user_log_file): else: level = "INFO" + if verbosity == 1: + # verbosity 1 means only subprocess logging is debug-level + # disabling capture of subprocess output + subprocess_level = "DEBUG" + subprocess_logger.setLevel(subprocess_level) + else: + subprocess_level = level + level_number = getattr(logging, level) # The "root" logger should match the "console" level *unless* we also need @@ -334,7 +342,7 @@ def setup_logging(verbosity, no_color, user_log_file): # A handler responsible for logging to the console messages # from the "subprocessor" logger. "console_subprocess": { - "level": level, + "level": subprocess_level, "class": handler_classes["stream"], "no_color": no_color, "stream": log_streams["stderr"], diff --git a/tests/unit/test_base_command.py b/tests/unit/test_base_command.py index 857d4f4f300..b0b7e92fda3 100644 --- a/tests/unit/test_base_command.py +++ b/tests/unit/test_base_command.py @@ -80,7 +80,7 @@ def test_raise_broken_stdout__debug_logging(self, capsys): """ Test raising BrokenStdoutLoggingError with debug logging enabled. """ - stderr = self.call_main(capsys, ['-v']) + stderr = self.call_main(capsys, ['-vv']) assert 'ERROR: Pipe to stdout was broken' in stderr assert 'Traceback (most recent call last):' in stderr diff --git a/tests/unit/test_utils_subprocess.py b/tests/unit/test_utils_subprocess.py index ecae2295c88..66e9b696836 100644 --- a/tests/unit/test_utils_subprocess.py +++ b/tests/unit/test_utils_subprocess.py @@ -255,6 +255,7 @@ def prepare_call(self, caplog, log_level, command=None): command = 'print("Hello"); print("world")' caplog.set_level(log_level) + subprocess_logger.setLevel(log_level) spinner = FakeSpinner() args = [sys.executable, '-c', command]