1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

Root logger should use debug level for "--log" (#3586)

We want the root logger to output debug level logs when we have
specified "--log".  The log-file handler then sends this to our file,
and the other handlers (console) filter out at their appropriate
level.

This restores the intended behaviour of "--log" argument, which is
supposed to output verbose logs to a file always.

A test-case is added

Closes: #3351
This commit is contained in:
Ian Wienand 2016-05-11 09:05:42 +10:00 committed by Donald Stufft
parent b8f8b8ce9e
commit ec08a590d8
2 changed files with 19 additions and 1 deletions

View file

@ -117,6 +117,12 @@ class Command(object):
else:
level = "INFO"
# The root logger should match the "console" level *unless* we
# specified "--log" to send debug logs to a file.
root_level = level
if options.log:
root_level = "DEBUG"
logging_dictConfig({
"version": 1,
"disable_existing_loggers": False,
@ -155,7 +161,7 @@ class Command(object):
},
},
"root": {
"level": level,
"level": root_level,
"handlers": list(filter(None, [
"console",
"console_errors",

View file

@ -846,6 +846,18 @@ def test_install_subprocess_output_handling(script, data):
assert 1 == result.stdout.count("I DIE, I DIE")
def test_install_log(script, data, tmpdir):
# test that verbose logs go to "--log" file
f = tmpdir.join("log.txt")
args = ['--log=%s' % f,
'install', data.src.join('chattymodule')]
result = script.pip(*args)
assert 0 == result.stdout.count("HELLO FROM CHATTYMODULE")
with open(f, 'r') as fp:
# one from egg_info, one from install
assert 2 == fp.read().count("HELLO FROM CHATTYMODULE")
def test_install_topological_sort(script, data):
args = ['install', 'TopoRequires4', '-f', data.packages]
res = str(script.pip(*args, expect_error=False))