Behavior changes based on presense of colorama
See original GitHub issueWithout colorama installed, the provided ColoredFormatter will always use colors, even when redirected to a file (ie. $ ./command.py 2> error_out.txt)
When colorama is installed, colorama detects a non-tty, and strips the colors.
Since colorlog provides a TTYColoredFormater that will strip colors for a non-tty, the above behavior seems not only inconsistent, but unintended. (ie. the user chooses stripping for non-tty by choosing TTYColoredFormater instead of ColoredFormatter, not by having or not having colorama installed.)
I therefore suggest that the colorama init should be called as:
colorama.init(strip=False)
or minimally some other option should be available to colorlog users to ‘force’ colors or prevent stripping.
I like my logs to have color even when redirected to files. Using ‘less -R’ let’s you still benefit from the colors when reviewing the output.
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
Not sure what happened to the commit in #41. I don’t currently have a setup that I can build and publish
colorlog
with, so I won’t be able to fix this until next week.thanks @borntyping