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

Colorize Log Output #1109

Merged
merged 9 commits into from Aug 8, 2013

Conversation

Projects
None yet
3 participants
@dstufft
Member

dstufft commented Aug 5, 2013

This colorized all log output for logging levels >= WARN. It uses yellow for WARN and red for ERROR/FATAL.

It will intelligently disable coloring when it's not suitable (such as when piping to a file) and it should support colorization on Windows as well (this uses Colorama but I have not tested it).

It vendors the BSD licensed colorama package.

It also introduces a new a new logger method Log.deprecated which takes a position argument for the version that the deprecated item is slated to be removed in. It will then set the log level to WARN or ERROR based on how many versions until the deprecated item is slated to be removed (WARN is > 1, ERROR otherwise).

It also moves the warning messages introduced in dc55947 to the new Log.deprecated method.

This fixes #1099 but the Log.deprecated work depends on a resolution to the backwards compatibility question (Semver vs Django style). It is currently written to support Django style but could easily be adapted to Semver.

Here is a picture of the logged messages at the warn and error levels:

Logged Errors

@alex

View changes

Show outdated Hide outdated pip/basecommand.py
@alex

View changes

Show outdated Hide outdated pip/log.py
@alex

View changes

Show outdated Hide outdated pip/log.py
Show outdated Hide outdated pip/log.py
@qwcode

This comment has been minimized.

Show comment
Hide comment
@qwcode

qwcode Aug 5, 2013

Contributor

cool, how about tests for should_color and the version comparison in deprecated. maybe factor out the version comparison for easier testing.

Contributor

qwcode commented Aug 5, 2013

cool, how about tests for should_color and the version comparison in deprecated. maybe factor out the version comparison for easier testing.

@dstufft

This comment has been minimized.

Show comment
Hide comment
@dstufft

dstufft Aug 5, 2013

Member

Ok version comparison has been split out into should_warn() and both should_warn() and should_color() have unit tests written for them.

Member

dstufft commented Aug 5, 2013

Ok version comparison has been split out into should_warn() and both should_warn() and should_color() have unit tests written for them.

dstufft added a commit that referenced this pull request Aug 8, 2013

@dstufft dstufft merged commit 5d2b6b3 into pypa:develop Aug 8, 2013

1 check passed

default The Travis CI build passed
Details

@dstufft dstufft deleted the dstufft:better-warning-output branch Aug 8, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment