#!/bin/sh
# Helper script to strip dates as well as line numbers from logfiles created by
# UDD importers (may be others?) to enable a proper diff
# also Python code line numbers are removed

if [ $# != 2 ] ; then
    echo "Usage `basename $0` oldlog newlog"
    exit 1
fi

oldlog="$1"
if [ ! -e "$oldlog" ] ; then
    echo "No such old logfile $oldlog."
    exit 1
fi

newlog="$2"
if [ ! -e "$newlog" ] ; then
    echo "No such new logfile $newlog."
    exit 1
fi

strip_log () {
   sed -e 's/^[-0-9]\{10\} [0-9:,]\{8,12\}[- ]\+//' \
       -e 's/ - ([0-9]\+):/:/' \
       "$1" > "${1}_strip"

}

strip_log "$oldlog"
strip_log "$newlog"

diff -u "${oldlog}_strip" "${newlog}_strip"
