Skip to content

Instantly share code, notes, and snippets.

@rroemhild
Created September 22, 2009 10:16
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save rroemhild/190970 to your computer and use it in GitHub Desktop.
Save rroemhild/190970 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="LOCAL4" # Syslog facility
PROG="´basename $0´" # Program name
SYSLOG="YES" # Write to Syslog? (YES/NO)
VERBOSE="NO" # Write to STDOUT? (YES/NO)
# Function: log()
# Usage: log priority "message"
log()
{
[ "$VERBOSE" = "YES" ] && echo "`date '+%b %e %H:%M:%S'`: $2"
[ "$SYSLOG" = "YES" ] && $LOGGER -t $PROG -p $FACILITY.$1 $2
}
@Keerthu8999
Copy link

bvjn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment