sponsor Vim development Vim logo Vim Book Ad

LogViewer : Comfortable examination of multiple parallel logfiles.

 script karma  Rating 4/3, Downloaded by 298    Comments, bugs, improvements  Vim wiki

created by
Ingo Karkat
 
script type
utility
 
description
DESCRIPTION
Many applications produce multiple log files; there may be one per component
or one production log and a separate debug log, or one from the server daemon
and one from the client application. During analysis, one may need to step
through them in tandem, when one provides details that the other doesn't.
Doing this manually in split windows is tedious; 'scrollbind' usually doesn't
help because different amounts of log lines are written to each file.

As long as each log file provides a timestamp or similar monotonically
increasing field, this plugin automatically syncs the cursor movement in one
log window to all other windows. When moving to another line in the current
window, all log lines that fall in the time range covered by the movement are
highlighted automatically.

An example screenshot can be found at
    http://ingo-karkat.de/swdev/vim/LogViewer.png

USAGE
The plugin is either activated automatically for the 'filetype' values in
g:LogViewer_Filetypes, or it can be manually activated for any buffer with
the :LogViewerEnable command.
With the default automatic syncing, any log buffer will automatically set up
the corresponding autocommands; without it, you need to kick off syncing in
one buffer via :LogViewerMaster. The current line in the current buffer will
be highlighted and marked with the "T" (for target) sign:
T 2012-08-01 10:01:22.342

When you move to another line, the plugin will mark the synced move in other
buffers to an adjacent line like this:
  2012-08-01 10:01:22.342
> 2012-08-01 10:01:23.234
When the timespan in the current buffer covers multiple log lines in another
buffer, the start of the range is marked with "-" and the end of the range
with "V" (downward move) / "^" (upward move):
  2012-08-01 10:01:22.342
- 2012-08-01 10:01:23.234
  2012-08-01 10:01:23.250
V 2012-08-01 10:01:26.012

:LogViewerEnable        Consider the current buffer as a log (even though its
                        'filetype' does not automatically make it one).

:LogViewerDisable       Exclude the current buffer from the log syncing; any
                        signs and automatic updates are removed from it.

:LogViewerMaster        Designate the current buffer as the log master. Only
                        cursor movements in this buffer will sync to other
                        buffers; movements in other buffers won't affect the
                        markers any more.

:LogViewerUpdate CursorMoved | CursorHold | Manual
                        Set the trigger for the syncing to the passed event.
                        By default, each cursor movement will immediately
                        update all other log buffers. With CursorHold, this
                        will only happen after 'updatetime'. With Manual, it
                        has to be explicitly triggered with
                        :LogViewerTarget.

:LogViewerTarget        Set the target log line (the basis for the
                        highlighting in all other log buffers) to the current
                        line in the current buffer.
:[count]LogViewerTarget Set the target log line to [count] timestamps down
                        from the current target timestamp.
:LogViewerTarget {timestamp}
                        Set the target log line to the first timestamp that
                        matches {timestamp}. Useful to proceed to the
                        beginning of a date when interesting things have
                        happened.
 
install details
INSTALLATION
This script is packaged as a vimball. If you have the "gunzip" decompressor
in your PATH, simply edit the *.vmb.gz package in Vim; otherwise, decompress
the archive first, e.g. using WinZip. Inside Vim, install by sourcing the
vimball or via the :UseVimball command.
    vim LogViewer*.vmb.gz
    :so %
To uninstall, use the :RmVimball command.

DEPENDENCIES
- Requires Vim 7.0 or higher.
- Requires the ingo-library.vim plugin (vimscript #4433), version 1.008 or
  higher.

CONFIGURATION
For a permanent configuration, put the following commands into your vimrc:

To change the default update trigger (that can be switched via
:LogViewerUpdate to Manual :
    let g:LogViewer_SyncUpdate = 'Manual'

By default, there is no master log file; movements in any log buffer cause
syncing in the other buffers. To turn that off:
    let g:LogViewer_SyncAll = 0
You will need to use :LogViewerMaster on one log buffer to start the
syncing.

Only buffers with certain filetypes are considered log files. The setting is a
comma-separated list of filetypes (autocmd-patterns):
    let g:LogViewer_Filetypes = 'log4j,syslog'

By default, the timestamp is expected as a whitespace-separated decimal number
starting at the first column. You should define the appropriate timestamp
format for each log filetype (from g:LogViewer_Filetypes). Typically, this
is done in ~/.vim//ftplugin/{filetype}_LogViewer.vim. For example, the log4j
timestamp pattern corresponding to the "%d" format is:
    let b:logTimestampExpr = '^\d\S\+\d \d\S\+\d\ze\s' " %d, e.g. 2011-08-17 13:08:30,509
To determine the chronological order, LogViewer uses a numerical compare for
integer timestamps, and case-sensitive string comparison for everything else.

To mark the current target logline and the corresponding log line ranges in
the other log buffers, LogViewer uses signs:
    LogViewerTarget     The target log line at the current cursor position, or
                        set via :LogViewerTarget
    LogViewerFrom       The (earliest when moving down towards later log
                        entries) log line corresponding to the move of the
                        target.
    LogViewerTo         The last log line corresponding to the move of the
                        target.

You can redefine the sign definitions after the plugin/LogViewer.vim script
has been sourced, e.g.:
    runtime plugin/LogViewer.vim
    sign define LogViewerTarget   text=T linehl=CursorLine

The default signs use line highlighting for a |hl-CursorLine|-like visual
indication of the positions (the 'cursorline' setting is disabled
automatically for log windows); you can define you own colors for those, too:
    highlight LogViewerTarget gui=underline guibg=Red
 

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
LogViewer-1.10.vmb.gz 1.10 2014-10-29 7.0 Ingo Karkat - Syncing on the CursorMoved event disturbs the selection, making it impossible to select multiple log lines. Explicitly restore the visual selection.
- Add b:logTimestampExpr definition for log4j filetype to the plugin.
- Add :LogViewerEnable / :LogViewerDisable commands to explicitly manage individual buffers, and allow use of the plugin for filetypes that haven't been included in g:LogViewer_Filetypes.
- Add dependency to ingo-library (vimscript #4433). *** You need to separately install ingo-library (vimscript #4433) version 1.008 (or higher)! ***
LogViewer.vba.gz 1.00 2012-08-01 7.0 Ingo Karkat Initial upload
ip used for rating: 54.204.73.126

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.
   
SourceForge.net Logo