如何在python日志中使行号着色?

2024-09-27 01:24:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我想把记录语句的行号涂上颜色。据我所知,我必须为此编写一个完整的新代码[1]。有没有更短的方法让下面的线条变彩色?i、 e更改%(lineno)d'部分,使终端在行号中具有颜色。谢谢。你知道吗

logging.basicConfig(level=logging.DEBUG,
       format='%(name)-12s %(funcName)s() %(message)s %(lineno)d')  
logger = logging.getLogger(__name__)

[1]Python Colorlog not printing in the log files with colors


Tags: 方法代码namedebug终端颜色logging记录

热门问题