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
I discovered the following solution. Apparently Pycharm redirects sys.stdout. From the sys module documentation:
sys.__stdin__
sys.__stdout__
sys.__stderr__
These objects contain the original values of stdin, stderr and stdout at the start of the program. They are used during finalization, and could be useful to print to the actual standard stream no matter if the sys.std* object has been redirected.
It can also be used to restore the actual files to known working file objects in case they have been overwritten with a broken object. However, the preferred way to do this is to explicitly save the previous stream before replacing it, and restore the saved object.
Therefore, to solve this issue you can redirect output to sys.__stdout__. Example configuration from my log_config.yml:
console:
class: logging.StreamHandler
level: DEBUG
stream: "ext://sys.__stdout__"
formatter: colorFormatter