Source

css / bin / dlog

Full commit
#!/bin/sh -u
#
# Log an action to $LOGDIR/dlog-quick and also via buglog's dlog facility,
# which uses buglog-daily.      - Cameron Simpson <cs@zip.com.au>
# 

cmd=$0
usage="Usage: $cmd [-l {log|logfile}] [remark...]"
trace=  ##set-x
echo=:
[ -t 2 ] && echo=eecho

: ${LOGDIR:=$HOME/var/log}

when=${DLOG_WHEN:-}

[ -t 0 ] && exec </dev/null

if not flag DLOG_LOCAL && [ "x$HOST" != "x$HOMEHOST" ]
then
  if flag DLOG_REMOTE_DISABLE
  then
    $echo "$cmd: flag DLOG_REMOTE_DISABLE: logging locally"
  else
    exec $trace sshx "$HOMEHOST" ./bin/with-login-env dlog ${1+"$@"}
  fi
fi

logname=dlog-quick
[ $# -gt 0 ] && [ "x$1" = x-l ] && { logname=$2; shift; shift; }
case "$logname" in /*) ;; *) logname=$LOGDIR/$logname ;; esac
[ $# = 0 ] && exec pageif cat "$logname"

if [ -n "$when" ]
then  ts=`date -d "$DLOG_WHEN" '+%Y-%m-%d-%H:%M:%S'`
else  ts=`date '+%Y-%m-%d-%H:%M:%S'`
fi
echo "$ts $*" >>"$logname"
exec buglog -B dlog "$*"