sponsor Vim development Vim logo Vim Book Ad

vim-logreview : plugin to help log reviews and navigation

 script karma  Rating 9/3, Downloaded by 915  Comments, bugs, improvements  Vim wiki

created by
Andres Hazard
 
script type
utility
 
description
https://github.com/andreshazard/vim-logreview

At work I usually have go through Java and Apache log files, looking for specific errors, logs at a certain time range, searching for logs of a specific class, etc. I do this using VIM so I created a plugin for it. I'm not sure how useful it is for logs created by other languages and hosting but I think is not that different or it can be tweak to suit the needs of other situations.

vim-logreview

Plugin to help review logs files within VIM.
This was created with Java log files in mind, however the funcionallity could work
for other log files as well or you can edit this plugin or send a pull requeest to suite your needs.

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.

http://i.imgur.com/uQoem3G.png


Functions

The plugin will load the following commands when working with a logreview file types.

`:RemoveDEBUGLogs` Will remove all lines containing a "DEBUG" log <br>
`:RemoveINFOLogs` Will remove all lines containing a "INFO" log <br>
`:RemoveGREENLogs` Will remove all lines containing a "INFO" or "DEBUG" log <br>
`:RemoveWARNLogs` Will remove all lines containing a "WARN" log <br>
`:RemoveAllButERRORLogs` Will remove all lines that do not contain an "ERROR" log <br>
`:RemoveAtExpLogs` Will remove all lines that contain an " at com.project.package classname test" type log <br>

http://i.imgur.com/ppv97Qx.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 containing 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 containing 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.

i.imgur.com/VsouksS.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.

i.imgur.com/rrVUKji.gif

Mappings

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

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

 
install details
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'
```
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
vim-logreview.tar 1.0 2016-05-09 7.0 Andres Hazard Initial upload
ip used for rating: 18.97.14.85

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github