Skip to content

Instantly share code, notes, and snippets.

@paulmooring
Created July 5, 2013 21:21
Show Gist options
  • Save paulmooring/5937337 to your computer and use it in GitHub Desktop.
Save paulmooring/5937337 to your computer and use it in GitHub Desktop.
########## Syslog priorities ##########
CRIT="user.crit"
ERROR="user.err"
WARN="user.warn"
NOTICE="user.notice"
INFO="user.info"
DEBUG="user.debug"
#######################################
debug(){
if [ -z $2 ] ; then
lvl=0
else
lvl=$2
fi
if [[ $verb -gt $lvl ]] ; then
echo $1
fi
}
log(){
PRIORITY=$1
msg=${@}
if [ -z $log ] ; then
hash logger 2>/dev/null
if [ $? -eq 0 ] ; then
log="true"
else
log="false"
fi
fi
if [[ $log == "true" ]] ; then
logger -t $0 -p $PRIORITY $msg
debug "${msg[@]}"
else
debug "${msg[@]}"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment