Created
July 31, 2015 08:47
-
-
Save jujhars13/4146f924daab51d4df80 to your computer and use it in GitHub Desktop.
log stuff with info and error convenience methods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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