Skip to content

kernc/diff-logs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 

Repository files navigation

diff-logs

Build Status Language: Perl Source lines of code Script size Bug tracker

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

Quickly find difference lines in all kinds of logs, namely build/CI logs, server/container logs, or any similar such. Figure out quickly what changed and why exactly your shit is failing.

The script works by simply replacing common stochastic string patterns, such as datetime timestamps, download speeds, temporary filenames, HTTP header values, UUIDs, hash digests etc. 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. Put diff-logs script into your bin-dir or elsewhere on $PATH:
    curl -vL https://github.com/kernc/diff-logs/raw/refs/heads/master/diff-logs
        sudo tee /usr/local/bin/diff-logs
    sudo chmod +x /usr/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

Notes

This once was Python, but Perl is even more ubiquituous.


Finally, we can diff our logs with ease! 🥳

Improvements and additions welcome!