s4

changeset 798:91016ff5edb3 feature-world

Gather logs of all worlds into master logfile
author HIROSE Yuuji <yuuji@gentei.org>
date Sun, 14 Jun 2020 11:16:41 +0900
parents 56adb6e5ee68
children e516626923f7
files s4-funcs.sh
diffstat 1 files changed, 11 insertions(+), 9 deletions(-) [+]
line diff
     1.1 --- a/s4-funcs.sh	Sun Jun 14 11:15:45 2020 +0900
     1.2 +++ b/s4-funcs.sh	Sun Jun 14 11:16:41 2020 +0900
     1.3 @@ -28,9 +28,10 @@
     1.4  PATH=/usr/local/sqlite3/bin:/usr/local/vim7/bin:/usr/iekei/ImageMagick/bin:/usr/local/ImageMagick/bin:$PATH
     1.5  tmpdir=${TMPDIR:-tmp}
     1.6  dbdir=${DBDIR:-db}
     1.7 +logdir=${LOGDIR:-tmp}
     1.8  tmpfiles=""
     1.9 -querylog=${QUERYLOG:-$tmpdir/query.log}
    1.10 -searchlog=${SEARCHLOG:-$tmpdir/search.log}
    1.11 +querylog=${QUERYLOG:-$logdir/query.log}
    1.12 +searchlog=${SEARCHLOG:-$logdir/search.log}
    1.13  db=${DB:-$dbdir/cgi.sq3}
    1.14  sessdb=${SESSDB:-$dbdir/sess.sq3}
    1.15  userupdateflag=$dbdir/userupdate
    1.16 @@ -84,9 +85,10 @@
    1.17  iconcachekey="profimgcache_S"
    1.18  
    1.19  # Start debug logging
    1.20 -exec 3>> $tmpdir/debug.out
    1.21 +logtag="${S4WORLD:+\{$S4WORLD\}}"
    1.22 +exec 3>> $logdir/debug.out
    1.23  err() {
    1.24 -  echo "[`date +%F-%T%z`] $@" 1>&3
    1.25 +  echo "[`date +%F-%T%z`]$logtag $@" 1>&3
    1.26  }
    1.27  case "$HTTP_USER_AGENT" in
    1.28    *i[Pp]hone*|*[Aa]ndroid*)	touchpanel=1 ;;
    1.29 @@ -97,7 +99,7 @@
    1.30  ### if [ -n "$S4MASTERDB" -a -s "$S4MASTERDB" ]; then
    1.31  # If S4WORLDLIST is set, this s4 have world!
    1.32  if [ -n "$S4WORLDLIST" ]; then
    1.33 -  . ./s4-world.sh 2>> tmp/debug.out
    1.34 +  . ./s4-world.sh 2>> $logdir/debug.out
    1.35    # Variables set in s4-world.sh
    1.36    #	$S4WORLDS, $S4WROLDNAME, $S4WORLDGRPS
    1.37    # Files created in s4-world.sh
    1.38 @@ -372,10 +374,10 @@
    1.39  EOF
    1.40  
    1.41  logstart() {
    1.42 -  echo "`date '+%F %T'`:[${user:-NULL}] <<<" >> ${1:-$querylog}
    1.43 +  echo "`date '+%F %T'`:[${user:-NULL}]$logtag <<<" >> ${1:-$querylog}
    1.44  }
    1.45  logend() {
    1.46 -  echo ">>>" >> ${1:-$querylog}
    1.47 +  echo ">>>$logtag" >> ${1:-$querylog}
    1.48  }
    1.49  sqlog() {
    1.50    logstart
    1.51 @@ -410,10 +412,10 @@
    1.52    sq  $db < $sqi &
    1.53    sq3pid="`jobs -p` $!"
    1.54    if $isCGI; then
    1.55 -     exec 2>> $tmpdir/error.out
    1.56 +     exec 2>> $logdir/error.out
    1.57    fi
    1.58    exec 5> $sqi # Turning $sqi access through fd5 for continuous open state
    1.59 -  chmod o-r $tmpdir/error.out $tmpdir/debug.out
    1.60 +  chmod o-r $logdir/error.out $logdir/debug.out
    1.61    rm $sqi
    1.62    # Attach supplemental DB
    1.63    cat >&5 <<-EOF