#!/bin/bash

#$1: log messge path: tmp or var
#$2: syslog trace level: fatal,error,warning,info,trace

if [ $1 ]; then
    path=$1
else
    path="tmp"
fi
if [ $2 ]; then
    level=$2
else
    level="trace"
fi

if [ $level == "trace" ]; then
    tail -fF /$path/log/messages | egrep '\.(debug|info|warning|err|crit) : '
elif [ $level == "info" ]; then
    tail -fF /$path/log/messages | egrep '\.(info|warning|err|crit) : '
elif [ $level == "warning" ]; then
    tail -fF /$path/log/messages | egrep '\.(warning|err|crit) : '
elif [ $level == "error" ]; then
    tail -fF /$path/log/messages | egrep '\.(err|crit) : '
else
    tail -fF /$path/log/messages | egrep '\.crit : '
fi

exit 0

