python-coloredlogs icon indicating copy to clipboard operation
python-coloredlogs copied to clipboard

coloredlogs output is only red in PyCharm

Open nibu147 opened this issue 4 years ago • 4 comments

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?

nibu147 avatar Mar 20 '20 12:03 nibu147

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

bwuerkner avatar Mar 26 '20 09:03 bwuerkner

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

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

haidaraM avatar Apr 03 '20 07:04 haidaraM

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 avatar Aug 02 '20 15:08 sudoerChris

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

sudoerChris avatar Aug 03 '20 10:08 sudoerChris