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

coloredlogs output is only red in PyCharm #85

Open
nibu147 opened this issue Mar 20, 2020 · 4 comments
Open

coloredlogs output is only red in PyCharm #85

nibu147 opened this issue Mar 20, 2020 · 4 comments

Comments

@nibu147
Copy link

nibu147 commented Mar 20, 2020

Hello,
since a few weeks, coloredlogs doesn't display colors properly anymore in the PyCharm console. It did before!
If I run the same code from terminal, everything works fine.
I can see only red text for logging output. print() statements are usually displayed with white font.
Anybody else having this issue?

@bwuerkner
Copy link

bwuerkner commented Mar 26, 2020

I have the same issue in visual studio code
I'm not conviced that it's coloredlogs fault though since when I go back to version 9.0 it still only displays in red

@haidaraM
Copy link

haidaraM commented Apr 3, 2020

In Pycharm, you need to enable Emulate terminal in output console in your run configuration options.

Source: https://stackoverflow.com/a/45534743

@sudoerChris
Copy link

same issue, however, if you log with ansi color, the message is displaying color correctly
sample code:

#after coloredlogs.install
logging.warning("\033[38;2;255;178;4mtest")

after this, all the logging becomes yellow, it seems like coloredlogs is not printing any effective ANSI escapes at all

sudoerChris added a commit to sudoerChris/python-coloredlogs that referenced this issue Aug 3, 2020
respect isatty parameter to force enable ANSI escape sequence
fix issue xolox#85
@sudoerChris
Copy link

UPDATE & WORKAROUND
the root cause of this problem is the sys.stderr.isatty() which is used in humanfriendly (to check if the stream is connected to a terminal) returns False in python console, which makes coloredlogs to disable ANSI escape sequences during initialization, a patch is uploaded #97 so you can use isatty=True to force enable ANSI escape sequences

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants