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.
I discovered the following solution. Apparently Pycharm redirects sys.stdout. From the sys module documentation:
Therefore, to solve this issue you can redirect output to
sys.__stdout__
. Example configuration from my log_config.yml: