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
Option isatty=True not always working #84
Comments
I am also having this issue. Looking at the source code, it would appear that only As for use cases, I've personally been having some issues with this since I'm calling my script through a job scheduler like cron (which disables coloring since it's not being called through a terminal). I've managed to find a workaround without changing the source code by making the scheduler call |
use could install my version locally, just executing command |
I basically have the same problem, but with a different usecase. My Python code runs a shared GitLab runner and I do pass |
@heni Your patch works for me in the GitLab runner. |
Hi all and thanks for the feedback. I've just published coloredlogs release 14.1 which fixes this issue. |
220: Update coloredlogs to 15.0 r=duckinator a=pyup-bot This PR updates [coloredlogs](https://pypi.org/project/coloredlogs) from **14.0** to **15.0**. <details> <summary>Changelog</summary> ### 15.0 ``` ---------------------------- Don't enable system logging on MacOS and Windows anymore. This is backwards incompatible (which is why I'm bumping the major version number) however the old behavior has been reported to be rather problematic (see :func:`~coloredlogs.syslog.is_syslog_supported()` for details) so this seems like the best choice. .. _Release 15.0: xolox/python-coloredlogs@14.2...15.0 ``` ### 14.3 ``` ---------------------------- Merged pull request `89`_ which enhances :func:`coloredlogs.install()` to preserve the filters on handlers that are replaced by :pypi:`coloredlogs`. .. _Release 14.3: xolox/python-coloredlogs@14.2...14.3 .. _89: xolox/python-coloredlogs#89 ``` ### 14.2 ``` ---------------------------- Honor the ``$NO_COLOR`` environment variable as suggested in issue `88`_. .. _Release 14.2: xolox/python-coloredlogs@14.1...14.2 .. _88: xolox/python-coloredlogs#88 ``` ### 14.1 ``` ---------------------------- **Bug fixes:** - Don't allow interactive terminal detection to disable colored text when colored text is being forced by the caller (reported in issue `84`_). - Automatically disable colored text when logging output is being redirected to a file in such a way that it actually works 😬 (reported in issue `100`_). **Other changes:** - Start testing on PyPy 3 (because why not?) .. _Release 14.1: xolox/python-coloredlogs@14.0...14.1 .. _84: xolox/python-coloredlogs#84 .. _100: xolox/python-coloredlogs#100 ``` </details> <details> <summary>Links</summary> - PyPI: https://pypi.org/project/coloredlogs - Changelog: https://pyup.io/changelogs/coloredlogs/ - Docs: https://coloredlogs.readthedocs.io </details> Co-authored-by: pyup-bot <github-bot@pyup.io> Co-authored-by: Ellen Marie Dash <me@duckie.co>
Detected issue
When passing the parameter
isatty=True
to the methodcoloredlogs.install()
the logger does not always generate a colored output.Conditions
I use this option because I run on windows and use a git bash terminal. Since git bash is using pipes it's not detecting the terminal correctly with
sys.stdout.isatty()
.Expected behavior
I would expect with the
isatty=True
to the methodcoloredlogs.install()
that the colored output is forced independent ofsys.stdout.isatty()
.Version
This has been discovered when running on version 14.0.
More information on issue
Debugging the module has shown that the method
terminal_supports_colors(stream)
returns false and the use_colors gets deactivated. More debugging has shown that in there thesys.stdout.isatty()
is called.Looking at those lines there is no difference from
'isatty'=None
and'isatty'=True
.Possible fix
For me changing line 433 to
if use_colors is None:
solved the issue. But I cannot tell if this is a valid fix, since I do not know other use cases.The text was updated successfully, but these errors were encountered: