Shell/Python程序:如何将日志文件转换为vim快速修复格式?

Shell/Python程序:如何将日志文件转换为vim快速修复格式?,python,shell,gcc,vim,format,Python,Shell,Gcc,Vim,Format,例如,我有一个这样的大日志文件: [2016-02-10 13:17:56.885597] [WARNING] [53171] [src/root/mylinux/test01.cpp:300] set errorformat+=\[%.%#\]\ \ \ \ \[%m\]\ \ \ \[%.%#\]\ \[%f:%l\] 如您所见,此格式包含几个部分: 1. The time stamp, day+hour+minute+second+microsecond 2. Some sp

例如,我有一个这样的大日志文件:

[2016-02-10 13:17:56.885597]    [WARNING]   [53171] [src/root/mylinux/test01.cpp:300]
set errorformat+=\[%.%#\]\ \ \ \ \[%m\]\ \ \ \[%.%#\]\ \[%f:%l\]
如您所见,此格式包含几个部分:

1. The time stamp, day+hour+minute+second+microsecond
2. Some spaces and the [WARNING] or [ERROR] or [INFO] or [DEBUG], etc.
3. A process ID number like [53171]
4. The source file name + line number
我希望将其格式更改为类似gcc错误信息的格式,例如:

test.cpp: In function ‘int main()’:
test.cpp:5: error: ‘pp’ was not declared in this scope
我希望使用VIM+quick fix导航我的日志文件并跳转到源文件,并查看程序如何执行

所以我的要求是:如何使用shell编程或python编程将日志文件格式更改为上述gcc错误格式


谢谢。

您可以如下设置Vim的
errorformat
选项:

[2016-02-10 13:17:56.885597]    [WARNING]   [53171] [src/root/mylinux/test01.cpp:300]
set errorformat+=\[%.%#\]\ \ \ \ \[%m\]\ \ \ \[%.%#\]\ \[%f:%l\]
这将为您提供以下结果以及您提供的样本:


提示:您可以使用
$vim-q mylog
直接在quickfix中打开日志。

vim的
quickfix
是数据结构,而不是文件格式。