Ⅰ. 插件描述
vim plugin for log navigationⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'andreshazard/vim-logreview'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'andreshazard/vim-logreview'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'andreshazard/vim-logreview'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/andreshazard/vim-logreview
Ⅳ. 文档说明
# vim-logreview
Plugin to help review logs files within VIM.
This was created with Java log files in mind, however the functionality could work
for other log files as well or you can edit this plugin or send a pull requeest to suite your needs.
Instalation
You can use Pathogen
git clone https://github.com/andreshazard/vim-logreview.git
~/.vim/bundle/vim-logreview.vimFor Vundle
add to your vimrc
Plugin 'andreshazard/vim-logreview'Usage
The plugin will detect your .log files and set the filetype as logreview.
If you need work with log files that do not have the .log extension.
You can run :
set filetype=logreviewThe logreview file types will have highlighting on specific keywords like : INFO, DEBUG, WARN, ERROR, etc. You can see
this on the syntax folder.

Functions
The plugin will load the following commands when working with a logreview file types.
:RemoveDEBUGLogs Will remove all lines containing a "DEBUG" log :RemoveINFOLogs Will remove all lines containing a "INFO" log :RemoveGREENLogs Will remove all lines containing a "INFO" or "DEBUG" log :RemoveWARNLogs Will remove all lines containing a "WARN" log :RemoveAllButERRORLogs Will remove all lines that do not contain an "ERROR" log :RemoveAllButCRITICALLogs Will remove all lines that do not contain a "CRITICAL" log :RemoveAtExpLogs Will remove all lines that contain an " at com.project.package classname test" type log

:RemoveButRangeDayTime day start end
This will remove all lines except the ones on the range you provided. For example you can call :
RemoveButRange 09 10:52 10:54
to get only the logs between 10:52 and 10:54 on day 09. This works
using the search command so a line cotaining those lines needs to exist on the file.
Example of a log line where this would work :
2016-04-07 10:52:04,459 [AsyncAppender-Dispatcher-Thread-18] DEBUG com.whatever.module.mail.service
:RemoveButRangeFullDateTime date start end
This will remove all lines except the ones on the range you provided. For example you can call :
RemoveButRange 08.04.2016 10:52 10:54
to get only the logs between 10:52 and 10:54 of the date 08.04.2016. This works
using the search command so a line cotaining those lines needs to exist on the file.
Example of a log line where this would work :
08.04.2016 10:52:04,459 [AsyncAppender-Dispatcher-Thread-18] DEBUG com.trainingrocket.module.mail.service
:RemoveAllButClass
This will remove all lines except the ones containing the string you passed to the function.
For example you can call :
RemoveAllBut com.example.my_bad_class to get only logs relatd to this class.

:FoldStackBelow
This will create a mark fold of the stack below the cursor. It assumes that the stack lines start
with at lease one space.

Mappings
You can map the commands that you use the most on your vimrc.
For example :
:nnoremap <leader>bf :call FoldStackBelow()<CR>