PyCharm 记录输出颜色 [英] PyCharm logging output colours

查看:65
本文介绍了PyCharm 记录输出颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 PyCharm 在 Mac OS X 中开发 GAE 应用程序.有什么方法可以在 PyCharm 的运行控制台中显示颜色?

我设置了一个 :将代码段的第 55 行从 sys.stderr 到 sys.stdout.stderr 流总是用红色着色,而 stdout 则不是.

现在颜色可以正确显示了.

解决方案

PyCharm 本身不支持该功能,但是您可以下载 Grep 控制台插件 并根据需要设置颜色.

这是一个屏幕截图:http://plugins.jetbrains.com/files/7125/screenshot_14104.png(链接失效)

我希望它有所帮助 :) 虽然它没有提供完全彩色的控制台,但它是朝着它迈出的一步.

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 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.

这篇关于PyCharm 记录输出颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆