]> git.plutz.net Git - cgilite/blobdiff - logging.sh
various refinements in new modules
[cgilite] / logging.sh
index f10ea4c43283842e4e188ec0f0306672caf9f96e..31bb24d3c4d3b9abbcb7bb175bcd455d5a078d2c 100755 (executable)
@@ -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