Skip to content
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

Decouple logs output color from the logging level #10763

Closed

Conversation

healthy-pod
Copy link

Previously, each logging level was coupled with a specific
output color. This isn't always ideal because we might need
to log at a certain level but use a custom color (based on
user feedback / see linked issue).

This patch decouples the logs output color from the logging
level.

Fixes #10519

@pradyunsg
Copy link
Member

Hurrah! Work for #10421 is making these little things easier as well!

@healthy-pod healthy-pod force-pushed the decouple_log_color_from_log_level branch from 12ccee9 to 3969a38 Compare January 6, 2022 08:12
@healthy-pod
Copy link
Author

Fixed (at least I think I did) a pre-commit issue in the last change. It's my first contribution to pip so feel free to let me know if there's anything I need to update!

@DiddiLeija
Copy link
Member

The linters are going well. The tests are currently failing because of #10742.

@pradyunsg pradyunsg closed this Jan 15, 2022
@pradyunsg pradyunsg reopened this Jan 15, 2022
@pradyunsg
Copy link
Member

Doing the close-reopen dance, in case GH actions runs on a simulated merge commit.

Copy link
Member

@webknjaz webknjaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@healthy-pod why did you add a "bugfix" change note? This seems to be a feature. Also, is the note text empty by accident?

On a side note: it may be worth splitting the addition of the mechanism that implements attaching colors to messages and using it. I'd imagine that the first part could benefit from some sort of automatic tests.

P.S. I see you're allowing color strings — would allowing to set the whole style too be useful?

src/pip/_internal/utils/logging.py Show resolved Hide resolved
@pradyunsg
Copy link
Member

pradyunsg commented Jan 16, 2022

Hiya @healthy-pod! Could you rebase1 this PR?

This branch was created at a point where the CI on main was broken, and thus, can't be merged as-is.

Footnotes

  1. If you're not familiar with this, you might find this article to be a useful read. :)

@healthy-pod healthy-pod force-pushed the decouple_log_color_from_log_level branch from 3969a38 to 564fd7f Compare January 16, 2022 06:49
@healthy-pod
Copy link
Author

Hiya @healthy-pod! Could you rebase1 this PR?

This branch was created at a point where the CI on main was broken, and thus, can't be merged as-is.

Done

@pradyunsg
Copy link
Member

I swear our CI is usually not a fickle beast like this. Ok, maybe it is...

Anyway, @healthy-pod could you rebase this again?

@healthy-pod healthy-pod force-pushed the decouple_log_color_from_log_level branch from 564fd7f to 4f0a222 Compare March 6, 2022 19:58
@healthy-pod
Copy link
Author

Anyway, @healthy-pod could you rebase this again?

Done

@pradyunsg
Copy link
Member

Oh hey, look! The test suite works, and there's tests that caught that you're spewing to stderr instead of stdout now. You'll likely need to fix those! :)

@pradyunsg
Copy link
Member

Hiya @healthy-pod! A gentle nudge on this -- this PR needs a minro update. If you won't have time to address this soon, please let me know and I'll pick it up. :)

@healthy-pod
Copy link
Author

Hiya @healthy-pod! A gentle nudge on this -- this PR needs a minro update. If you won't have time to address this soon, please let me know and I'll pick it up. :)

Thanks for the reminder @pradyunsg! I assume "critical" goes to stderr while "info" goes to stdout. I changed logger.info to logger.critical in factory.py which caused some tests expecting some output at stdout to get it at stderr. Is my analysis correct? If so, do we want to change the tests in this case (ie change what they expect)? I wonder what the tests did when the line I changed was originally logger.critical (ie before it was even changed to logger.info).

@healthy-pod healthy-pod force-pushed the decouple_log_color_from_log_level branch from 4f0a222 to d669bdc Compare May 8, 2022 03:41
Previously, each logging level was coupled with a specific
output color. This isn't always ideal because we might need
to log at a certain level but use a custom color (based on
user feedback / see linked issue).

This patch decouples the logs output color from the logging
level.

Fixes pypa#10519
@pradyunsg pradyunsg force-pushed the decouple_log_color_from_log_level branch from d669bdc to f3636d6 Compare November 24, 2022 17:57
@pradyunsg pradyunsg self-assigned this Nov 24, 2022
@pradyunsg pradyunsg added the type: enhancement Improvements to functionality label Nov 24, 2022
@healthy-pod healthy-pod closed this May 9, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: enhancement Improvements to functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"pip install --quiet" hides conflict information
4 participants