Skip to content

Shell utility for viewing differences between log files

Notifications You must be signed in to change notification settings

kernc/diff-logs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

diff-logs

Build Status

A command-line utility for diff'ing log files.

Quickly find diffing lines in all kinds of logs, namely build/CI logs, server/container logs or any such. Figure out why exactly the shit is failing quickly.

The script works by replacing common stochastic string patterns, such as datetime timestamps, download speeds, temporary files, HTTP header values, UUIDs, hash digests etc., with known fixed values that a tool such as diff can then easily skip.

Installation

First, check if your OS distro already provides an installable diff-logs package.

Otherwise:

  1. Star, download or clone repo.
  2. (Optional) Create a symlink in your bin-dir pointing to diff-logs shell script:
    mkdir -p ~/.local/bin
    export PATH="~/.local/bin:$PATH"    # Also put in .bashrc or similar
    # Link script into your bin
    ln -s ~/path/to/diff-logs/diff-logs ~/.local/bin/diff-logs

Usage

$ diff-logs --help

Usage: diff-logs < FILE1.log           # Print log file diff-friendly
       diff-logs FILE1.log FILE2.log   # Invoke $DIFFTOOL (e.g. diff)

Examples

Diff two log files

diff-logs FILE1 FILE2    # Invokes `diff`
# or
export DIFFTOOL=meld
diff-logs FILE1 FILE2    # Invokes `meld`

Diff-friendly-format a single log file

diff-logs < FILE1 > FILE1.clean

Finally, we can diff our logs with ease! 🥳

Improvements welcome!