hjking / vim-logreview

vim plugin for log navigation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.vim

For 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=logreview

The logreview file types will have highlighting on specific keywords like : INFO, DEBUG, WARN, ERROR, etc. You can see this on the syntax folder.

snapshot

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

gif

: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.

gif

: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.

gif

##Mappings

You can map the commands that you use the most on your vimrc. For example :

:nnoremap <leader>bf :call FoldStackBelow()<CR>

About

vim plugin for log navigation

License:GNU General Public License v3.0


Languages

Language:Vim Script 100.0%