Let logging format messages on demand

This commit is contained in:
Ville Skyttä 2015-12-27 01:04:40 +02:00
parent 1b2bedcd61
commit 8e436d994d
5 changed files with 19 additions and 21 deletions

View File

@ -44,9 +44,8 @@ class HashCommand(Command):
algorithm = options.algorithm
for path in args:
logger.info('%s:\n--hash=%s:%s' % (path,
algorithm,
_hash_of_file(path, algorithm)))
logger.info('%s:\n--hash=%s:%s',
path, algorithm, _hash_of_file(path, algorithm))
def _hash_of_file(path, algorithm):

View File

@ -107,25 +107,25 @@ def print_results(distributions, list_all_files):
for dist in distributions:
results_printed = True
logger.info("---")
logger.info("Metadata-Version: %s" % dist.get('metadata-version'))
logger.info("Name: %s" % dist['name'])
logger.info("Version: %s" % dist['version'])
logger.info("Summary: %s" % dist.get('summary'))
logger.info("Home-page: %s" % dist.get('home-page'))
logger.info("Author: %s" % dist.get('author'))
logger.info("Author-email: %s" % dist.get('author-email'))
logger.info("License: %s" % dist.get('license'))
logger.info("Location: %s" % dist['location'])
logger.info("Requires: %s" % ', '.join(dist['requires']))
logger.info("Metadata-Version: %s", dist.get('metadata-version'))
logger.info("Name: %s", dist['name'])
logger.info("Version: %s", dist['version'])
logger.info("Summary: %s", dist.get('summary'))
logger.info("Home-page: %s", dist.get('home-page'))
logger.info("Author: %s", dist.get('author'))
logger.info("Author-email: %s", dist.get('author-email'))
logger.info("License: %s", dist.get('license'))
logger.info("Location: %s", dist['location'])
logger.info("Requires: %s", ', '.join(dist['requires']))
if list_all_files:
logger.info("Files:")
if 'files' in dist:
for line in dist['files']:
logger.info(" %s" % line.strip())
logger.info(" %s", line.strip())
else:
logger.info("Cannot locate installed-files.txt")
if 'entry_points' in dist:
logger.info("Entry-points:")
for line in dist['entry_points']:
logger.info(" %s" % line.strip())
logger.info(" %s", line.strip())
return results_printed

View File

@ -271,8 +271,8 @@ class RequirementSet(object):
existing_req.extras = tuple(
sorted(set(existing_req.extras).union(
set(install_req.extras))))
logger.debug("Setting %s extras to: %s" % (
existing_req, existing_req.extras))
logger.debug("Setting %s extras to: %s",
existing_req, existing_req.extras)
# And now we need to scan this.
result = [existing_req]
# Canonicalise to the already-added object for the backref

View File

@ -151,9 +151,8 @@ def pip_version_check(session):
logger.warning(
"You are using pip version %s, however version %s is "
"available.\nYou should consider upgrading via the "
"'%s install --upgrade pip' command." % (pip_version,
pypi_version,
pip_cmd)
"'%s install --upgrade pip' command.",
pip_version, pypi_version, pip_cmd
)
except Exception:

View File

@ -41,7 +41,7 @@ def test_pip_version_check(monkeypatch, stored_time, newver, check, warn):
)
monkeypatch.setattr(outdated.logger, 'warning',
pretend.call_recorder(lambda s: None))
pretend.call_recorder(lambda *a, **kw: None))
monkeypatch.setattr(outdated.logger, 'debug',
pretend.call_recorder(lambda s, exc_info=None: None))