请使用Spyder python编辑器,最近安装了库coloredlogs。安装成功,然后我实际运行了http://coloredlogs.readthedocs.io/en/latest/readme.html(在“使用情况”部分下)共享的示例,当我运行spyder时,什么都没有发生。 这意味着,如果我选择Spyder Idle控制台,则发送到stdout的记录器数据只是黑色。 这是我正在测试的代码:
import coloredlogs, logging
# Create a logger object.
logger = logging.getLogger(__name__)
# By default the install() function installs a handler on the root logger,
# this means that log messages from your code and log messages from the
# libraries that you use will all show up on the terminal.
coloredlogs.install(level='DEBUG')
# If you don't want to see log messages from libraries, you can pass a
# specific logger object to the install() function. In this case only log
# messages originating from that logger will show up on the terminal.
coloredlogs.install(level='DEBUG', logger=logger)
# Some examples.
logger.debug("this is a debugging message")
logger.info("this is an informational message")
logger.warning("this is a warning message")
logger.error("this is an error message")
logger.critical("this is a critical message")
有人遇到过类似的问题吗? 我没有收到任何错误消息,但是根本看不到任何颜色,只有黑色字体。 谢谢