X-Git-Url: https://git.plutz.net/?p=cgilite;a=blobdiff_plain;f=logging.sh;h=31bb24d3c4d3b9abbcb7bb175bcd455d5a078d2c;hp=f10ea4c43283842e4e188ec0f0306672caf9f96e;hb=175ea9642bc5997c5e59b69f01a9f9d0e4f3039f;hpb=3b749d034d316a0f5b29683929153a3fbc04e947 diff --git a/logging.sh b/logging.sh index f10ea4c..31bb24d 100755 --- a/logging.sh +++ b/logging.sh @@ -12,14 +12,17 @@ LOGLEVEL="${LOGLEVEL:-3}" LOGFILE="${LOGFILE:-/dev/stderr}" logmsg(){ - if [ "${1:-3}" -le "$LOGLEVEL" ]; then - [ "$#" -gt 1 ] \ - && printf %s\\n "$*" >>"${LOGFILE}" \ - || tee -a "${LOGFILE}" + local ll="${1:-3}" + shift 1 + if [ "$ll" -le "$LOGLEVEL" -a "$#" -gt 0 ]; then + printf %s\\n "$*" >>"${LOGFILE}" + elif [ "$ll" -le "$LOGLEVEL" ]; then + tee -a "${LOGFILE}" + elif [ ! "$#" -gt 0 ]; then + cat fi } - die(){ [ "$#" -gt 0 ] && logmsg 1 "$@" exit 1