Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable verbose logging with --debug #12710

Merged
merged 2 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/12710.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Using ``--debug`` also enables verbose logging.
2 changes: 2 additions & 0 deletions src/pip/_internal/cli/base_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ def _main(self, args: List[str]) -> int:

# Set verbosity so that it can be used elsewhere.
self.verbosity = options.verbose - options.quiet
if options.debug_mode:
self.verbosity = 2

reconfigure(no_color=options.no_color)
level_number = setup_logging(
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/test_base_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ def test_handle_pip_version_check_called(mock_handle_version_check: Mock) -> Non
mock_handle_version_check.assert_called_once()


def test_debug_enables_verbose_logs() -> None:
cmd = FakeCommand()
cmd.main(["fake", "--debug"])
assert cmd.verbosity >= 2


def test_log_command_success(fixed_time: None, tmpdir: Path) -> None:
"""Test the --log option logs when command succeeds."""
cmd = FakeCommand()
Expand Down
Loading