I'm using PyCharm to develop a GAE app in Mac OS X. Is there any way to display colours in the run console of PyCharm?
I've set a handler to output colours in ansi format. Then, I've added the handler:
LOG = logging.getLogger()
LOG.setLevel(logging.DEBUG)
for handler in LOG.handlers:
LOG.removeHandler(handler)
LOG.addHandler(ColorHandler())
LOG.info('hello!')
LOG.warning('hello!')
LOG.debug('hello!')
LOG.error('hello!')
But the colour is the same.
EDIT:
A response from JetBrains issue tracker: Change line 55 of the snippet from sys.stderr to sys.stdout. stderr stream is always colored with red color while stdout not.
Now colours are properly displayed.
PyCharm 2019.1.1 (Windows 10, 1709) - runned snippet as is - works correctly.
Bug: setFormatter - does not work.
Fix: make change in line 67 and get rid on line 70-71 (unformatted handler adding).
to
Line 70-71 can be moved under manual file run construction for save test ability:
Compared it with standard StreamHandler:
Sept. 2019: PyCharm Community 2019.1
PyCharm colored all the logs including info/debug in red.
Th upshot is: it is not a PyCharm problem, this is how the default
logging
is configured. Everything written tosys.stderr
is colored red by PyCharm. When usingStreamHandler()
without arguments, the default stream issys.stderr
.For getting non-colored logs back, specify
logging.StreamHandler(stream=sys.stdout)
in basic config like this:or be more verbose:
This fixed my red PyCharm logs.
Late to the party, but anyone else with this issue, here's the solution that worked for me:
This came from this answer
As of at least PyCharm 2017.2 you can do this by enabling:
Run | Edit Configurations... | Configuration | Emulate terminal in output console
What solved it for me (on PyCharm 2017.2) was going to
Preferences -> Editor -> Color Scheme -> Console Colors
and changing the color ofConsole -> Error output
. Of course this also changes the error color but at least you don't see red all the time...PyCharm doesn't support that feature natively, however you can download the Grep Console plugin and set the colors as you like.
Here's a screenshot:
http://plugins.jetbrains.com/files/7125/screenshot_14104.png(link is dead)I hope it helps somewhat :) although it doesn't provide fully colorized console, but it's a step towards it.