def _setup_logging(self): """ Setup pip's logger. Ensure pip is verbose same as pip-tools and sync pip's log stream with LogContext.stream. """ # Default pip's logger is noisy, so decrease it's verbosity setup_logging( verbosity=log.verbosity - 1, no_color=self.options.no_color, user_log_file=self.options.log, ) # Sync pip's console handler stream with LogContext.stream logger = logging.getLogger() for handler in logger.handlers: if handler.name == "console": # pragma: no branch handler.stream = log.stream break else: # pragma: no cover # There is always a console handler. This warning would be a signal that # this block should be removed/revisited, because of pip possibly # refactored-out logging config. log.warning("Couldn't find a 'console' logging handler") # Sync pip's progress bars stream with LogContext.stream for bar_cls in itertools.chain(*BAR_TYPES.values()): bar_cls.file = log.stream
def _setup_logging(self) -> None: """ Setup pip's logger. Ensure pip is verbose same as pip-tools and sync pip's log stream with LogContext.stream. This is only necessary for pip<22.0. """ # Default pip's logger is noisy, so decrease it's verbosity setup_logging( verbosity=log.verbosity - 1, no_color=self.options.no_color, user_log_file=self.options.log, ) # Sync pip's console handler stream with LogContext.stream logger = logging.getLogger() for handler in logger.handlers: if handler.name == "console": # pragma: no branch assert isinstance(handler, logging.StreamHandler) handler.stream = log.stream break else: # pragma: no cover # There is always a console handler. This warning would be a signal that # this block should be removed/revisited, because of pip possibly # refactored-out logging config. log.warning("Couldn't find a 'console' logging handler") # This import will fail with pip 22.1, but here we're pip<22.0 from pip._internal.cli.progress_bars import BAR_TYPES # Sync pip's progress bars stream with LogContext.stream for bar_cls in itertools.chain(*BAR_TYPES.values()): bar_cls.file = log.stream
dest='quiet', action='count', default=0, help=( 'Give less output. Option is additive, and can be used up to 3' ' times (corresponding to WARNING, ERROR, and CRITICAL logging' ' levels).' ), ) # type: Callable[..., Option] progress_bar = partial( Option, '--progress-bar', dest='progress_bar', type='choice', choices=list(BAR_TYPES.keys()), default='on', help=( 'Specify type of progress to be displayed [' + '|'.join(BAR_TYPES.keys()) + '] (default: %default)' ), ) # type: Callable[..., Option] log = partial( PipOption, "--log", "--log-file", "--local-log", dest="log", metavar="path", type="path", help="Path to a verbose appending log." ) # type: Callable[..., Option]
dest="quiet", action="count", default=0, help=( "Give less output. Option is additive, and can be used up to 3" " times (corresponding to WARNING, ERROR, and CRITICAL logging" " levels)." ), ) # type: Callable[..., Option] progress_bar = partial( Option, "--progress-bar", dest="progress_bar", type="choice", choices=list(BAR_TYPES.keys()), default="on", help=( "Specify type of progress to be displayed [" + "|".join(BAR_TYPES.keys()) + "] (default: %default)" ), ) # type: Callable[..., Option] log = partial( PipOption, "--log", "--log-file", "--local-log", dest="log", metavar="path",
"-q", "--quiet", dest="quiet", action="count", default=0, help=("Give less output. Option is additive, and can be used up to 3" " times (corresponding to WARNING, ERROR, and CRITICAL logging" " levels)."), ) # type: Callable[..., Option] progress_bar = partial( Option, "--progress-bar", dest="progress_bar", type="choice", choices=list(BAR_TYPES.keys()), default="on", help=("Specify type of progress to be displayed [" + "|".join(BAR_TYPES.keys()) + "] (default: %default)"), ) # type: Callable[..., Option] log = partial( PipOption, "--log", "--log-file", "--local-log", dest="log", metavar="path", type="path", help="Path to a verbose appending log.", ) # type: Callable[..., Option]