Skip to content

Instantly share code, notes, and snippets.

@hybridadmin
Forked from rroemhild/gist:190970
Last active June 4, 2021 12:46
Show Gist options
  • Save hybridadmin/163adaf3dbce3ed4bdc1f5e76a9749c5 to your computer and use it in GitHub Desktop.
Save hybridadmin/163adaf3dbce3ed4bdc1f5e76a9749c5 to your computer and use it in GitHub Desktop.
simple shell script log function
# Vars for log()
LOGGER="/usr/bin/logger" # Path to logger
FACILITY="LOCAL2" # Syslog facility
PROG="´basename $0´" # Program name
SYSLOG="YES" # Write to Syslog? (YES/NO)
VERBOSE="YES" # Write to STDOUT? (YES/NO)
log(){
# Function: log()
# Usage: log priority "message"
[ "$VERBOSE" = "YES" ] && echo "`date +'%Y-%m-%d %H:%M:%S'`: $2"
[ "$SYSLOG" = "YES" ] && $LOGGER -t $PROG -p $FACILITY.$1 $2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment