为与python字符串或正则表达式匹配的纯文本行添加颜色
colorize.p的Python项目详细描述
着色.py
至少有一个existing tool可以执行自动语法突出显示 代码和输出ANSI转义序列。不幸的是 作者的知识,没有现有的工具来突出线的日志 包含特定模式的文件。vim的match和2match是 很接近,但使用起来有点笨拙。
此工具的目的是将与特定图案匹配的线条着色,以便 当仔细研究日志文件中的相关行时,可以更容易地突出显示这些行 与同事或经理的文件。
用法
假设我们有一个包含以下内容的文件:
This is an interesting line with some awesome content. unrelated line unrelated line unrelated line foobar Different topic of interest unrelated line
然后,我们可以运行以下命令来查看我们想要的一些效果:
colorize.py -h colorize.py -l colorize.py -f 'This is an interesting line=Blue' Input.log colorize.py -f 'This is an interesting line=Blue' -f 'Different topic=Red' Input.log # Note that we must run less in raw node to see the colors. colorize.py -f 'This is an interesting line=Blue' | less -R