Skip to content

Commit 6d47060

Browse files
Set default logging level to WARNING (#1178)
* Set default logging level to WARNING * Add changelog entry * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix typo * Apply shared parser as a parent parser for the base parser --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 81c2fa5 commit 6d47060

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## dev
22

3+
- Set default logging level to WARNING, so debug log messages won't be shown without passing additional flags such as `--verbose`
4+
5+
## 1.4.0
6+
37
- Delete directories directly instead of spawning rmdir on Windows
48
- Fix "Failed to delete" error when using Microsoft Store Python
59
- Fix "No pyvenv.cfg file" error when using Microsoft Store Python (#1164)

src/pipx/main.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -699,15 +699,6 @@ def get_command_parser() -> argparse.ArgumentParser:
699699

700700
completer_venvs = InstalledVenvsCompleter(venv_container)
701701

702-
parser = argparse.ArgumentParser(
703-
prog=prog_name(),
704-
formatter_class=LineWrapRawTextHelpFormatter,
705-
description=PIPX_DESCRIPTION,
706-
)
707-
parser.man_short_description = PIPX_DESCRIPTION.splitlines()[1] # type: ignore
708-
709-
subparsers = parser.add_subparsers(dest="command", description="Get help for commands with pipx COMMAND --help")
710-
711702
shared_parser = argparse.ArgumentParser(add_help=False)
712703

713704
shared_parser.add_argument(
@@ -723,6 +714,16 @@ def get_command_parser() -> argparse.ArgumentParser:
723714

724715
shared_parser.add_argument("--verbose", "-v", action="count", default=0, help=("Give more output."))
725716

717+
parser = argparse.ArgumentParser(
718+
prog=prog_name(),
719+
formatter_class=LineWrapRawTextHelpFormatter,
720+
description=PIPX_DESCRIPTION,
721+
parents=[shared_parser],
722+
)
723+
parser.man_short_description = PIPX_DESCRIPTION.splitlines()[1] # type: ignore
724+
725+
subparsers = parser.add_subparsers(dest="command", description="Get help for commands with pipx COMMAND --help")
726+
726727
_add_install(subparsers, shared_parser)
727728
_add_uninject(subparsers, completer_venvs.use, shared_parser)
728729
_add_inject(subparsers, completer_venvs.use, shared_parser)
@@ -786,12 +787,12 @@ def setup_log_file() -> Path:
786787
return _setup_log_file(platformdirs.user_log_path("pipx"))
787788

788789

789-
def setup_logging(verbose: bool) -> None:
790+
def setup_logging(verbose: int) -> None:
790791
pipx_str = bold(green("pipx >")) if sys.stdout.isatty() else "pipx >"
791792
pipx.constants.pipx_log_file = setup_log_file()
792793

793794
# Determine logging level
794-
level_number = max(0, 2 - verbose) * 10
795+
level_number = max(0, logging.WARNING - 10 * verbose)
795796

796797
level = logging.getLevelName(level_number)
797798

0 commit comments

Comments
 (0)