X-Git-Url: http://git.plutz.net/?p=cgilite;a=blobdiff_plain;f=logging.sh;fp=logging.sh;h=31bb24d3c4d3b9abbcb7bb175bcd455d5a078d2c;hp=f10ea4c43283842e4e188ec0f0306672caf9f96e;hb=3fe2a9ceb477adf245f6cc8f72fb61282e42c904;hpb=41bcab02ff4b11d22a2624e7afabc50e9c33ae2f 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