Skip to content

Instantly share code, notes, and snippets.

@cakyus
Last active July 23, 2020 11:19
Show Gist options
  • Save cakyus/666970c6ffd12ee4f550d42d852ae738 to your computer and use it in GitHub Desktop.
Save cakyus/666970c6ffd12ee4f550d42d852ae738 to your computer and use it in GitHub Desktop.
Bash Command Line
#!/bin/bash
if [ -z "$DEBUG" ]; then
DEBUG=0
fi
LOG_FILE=$( dirname $0 )/$( basename $0 .bash ).$( date +'%Y%m%d' ).log
logger_debug(){
if [ $DEBUG -eq 1 ]; then
>&2 echo $( date +'%Y-%m-%d+%H:%M:%S' ) DEBUG ${FUNCNAME[1]} $*
else
>&2 echo $( date +'%Y-%m-%d+%H:%M:%S' ) DEBUG ${FUNCNAME[1]} $* >> $LOG_FILE
fi
}
logger_error(){
>&2 echo $( date +'%Y-%m-%d+%H:%M:%S' ) ERROR ${FUNCNAME[1]} $*
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment