Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyCharm logging output colours

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.

PyCharm run console output

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.

like image 387
dablak Avatar asked Dec 02 '13 16:12

dablak


People also ask

How do I change the color of my logger?

Just use the color variables $BLACK - $WHITE in your log formatter string. To set the background just use $BG-BLACK - $BG-WHITE.

Where is output displayed in PyCharm?

If the checkbox is cleared, each time PyCharm finishes the INSERT statement from console_1, the IDE displays the output pane of console_1 in the Services tool window.

How do I copy output in PyCharm?

Shift/click at the start of the text you want to copy. (should now be highlighted) Right click and select copy.


2 Answers

As of at least PyCharm 2017.2 you can do this by enabling:

Run | Edit Configurations... | Configuration | Emulate terminal in output console

Run configuration

enter image description here

like image 126
phoenix Avatar answered Sep 27 '22 22:09

phoenix


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.

like image 40
metabuddy Avatar answered Sep 27 '22 20:09

metabuddy