Skip to content

Instantly share code, notes, and snippets.

@jujhars13
Created July 31, 2015 08:47
Show Gist options
  • Save jujhars13/4146f924daab51d4df80 to your computer and use it in GitHub Desktop.
Save jujhars13/4146f924daab51d4df80 to your computer and use it in GitHub Desktop.
log stuff with info and error convenience methods
#!/bin/bash
#####log stuff with info and error convenience methods
readonly log='/var/log/my_log_file.log'
if [ ! -f "$log" ];then #attempt to create log file
touch $log
if [ ! -f "$log_file" ];then #log file still not there (permissions?)
echo "Could not create a log file at ${log}"
exit 1
fi
fi
info(){
echo "`date`:INFO: ${1}" >>$log
}
error(){
echo "`date`:ERROR: ${1}" >>$log
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment