CYAN=""
NORMAL=""
-VERSION="0.3.8"
+VERSION="0.3.9"
STD_SHORT_OPTIONS="sdvhV"
STD_LONG_OPTIONS="simulate,debug,verbose,nocolor,help,version"
DO_ASK="n"
SIMULATE="n"
+LOGFILE=
+
declare -a REMAINING_ARGS=()
declare -a REMAINING_OPTS=()
if [[ "${VERBOSE}" != "y" ]] ; then
return 0
fi
- echo -e " * [$(my_date)] [${BASE_NAME}:${CYAN}DEBUG${NORMAL}]: $@" >&2
+ local ts=$(my_date)
+ if [[ -n "${LOGFILE}" ]] ; then
+ echo "[${ts}] [${BASE_NAME}DEBUG]: $@" >>"${LOGFILE}"
+ fi
+ echo -e " * [${ts}] [${BASE_NAME}:${CYAN}DEBUG${NORMAL}]: $@" >&2
}
#------------------------------------------------------------------------------
info() {
- echo -e " ${GREEN}*${NORMAL} [$(my_date)] [${BASE_NAME}:${GREEN}INFO${NORMAL}] : $@" >&2
+ local ts=$(my_date)
+ if [[ -n "${LOGFILE}" ]] ; then
+ echo "[${ts}] [${BASE_NAME}INFO] : $@" >>"${LOGFILE}"
+ fi
+ echo -e " ${GREEN}*${NORMAL} [${ts}] [${BASE_NAME}:${GREEN}INFO${NORMAL}] : $@" >&2
}
#------------------------------------------------------------------------------
warn() {
- echo -e " ${YELLOW}*${NORMAL} [$(my_date)] [${BASE_NAME}:${YELLOW}WARN${NORMAL}] : $@" >&2
+ local ts=$(my_date)
+ if [[ -n "${LOGFILE}" ]] ; then
+ echo "[${ts}] [${BASE_NAME}WARN] : $@" >>"${LOGFILE}"
+ fi
+ echo -e " ${YELLOW}*${NORMAL} [${ts}] [${BASE_NAME}:${YELLOW}WARN${NORMAL}] : $@" >&2
}
#------------------------------------------------------------------------------
error() {
- echo -e " ${RED}*${NORMAL} [$(my_date)] [${BASE_NAME}:${RED}ERROR${NORMAL}]: $@" >&2
+ local ts=$(my_date)
+ if [[ -n "${LOGFILE}" ]] ; then
+ echo "[${ts}] [${BASE_NAME}ERROR]: $@" >>"${LOGFILE}"
+ fi
+ echo -e " ${RED}*${NORMAL} [${ts}] [${BASE_NAME}:${RED}ERROR${NORMAL}]: $@" >&2
}
#------------------------------------------------------------------------------