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

fix colors in log on Windows #2012

Merged
merged 1 commit into from Jan 19, 2021
Merged

fix colors in log on Windows #2012

merged 1 commit into from Jan 19, 2021

Conversation

davidism
Copy link
Member

No longer requires Click, as click.style wasn't doing what I expected and other utilities weren't much use. Replaced with a simple wrapper with just the styles used. On Windows, style information is only added if Colorama is installed. The handler added to the "werkzeug" logger wraps the stream with colorama.AnsiToWin32 to output the styles correctly.

This means that if the user overrides the logging configuration, they'll get ANSI codes in the output again. However, that was already the case, even before the switch from termcolor to Click. If they're overriding logging, they can also make the decision to call colorama.init() before that to ensure sys.stderr is wrapped globally, but I didn't want Werkzeug to force that on import.

Also considered just removing styles. Until the recent switch to Click very few people ever saw them because termcolor wouldn't have been installed. For now I'll leave them in.

Checklist:

  • Add tests that demonstrate the correct behavior of the change. Tests should fail without the change.
  • Add or update relevant docs, in the docs folder and in code.
  • Add an entry in CHANGES.rst summarizing the change and linking to the issue.
  • Add .. versionchanged:: entries in any relevant code docs.
  • Run pre-commit hooks and fix any issues.
  • Run pytest and tox, no tests failed.

@davidism davidism added this to the 2.0.0 milestone Jan 19, 2021
no longer require click, require colorama for Windows
@davidism davidism merged commit 68b7cbd into master Jan 19, 2021
@davidism davidism deleted the server-log-color branch January 19, 2021 03:09
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fails to color Windows console
1 participant