s4

changeset 358:8166096f4b36

Record query into log
author HIROSE Yuuji <yuuji@gentei.org>
date Thu, 27 Oct 2016 21:22:27 +0859
parents 78c0a2b43ec1
children 44096124b0a6
files s4-funcs.sh
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line diff
     1.1 --- a/s4-funcs.sh	Thu Oct 27 17:05:36 2016 +0859
     1.2 +++ b/s4-funcs.sh	Thu Oct 27 21:22:27 2016 +0859
     1.3 @@ -31,6 +31,7 @@
     1.4  ### maximagexy=400x400
     1.5  file_accept='accept="image/*,text/*,audio/*,application/vnd.oasis.*,application/pdf,application/x-*"'
     1.6  blogreadflagrowid=0
     1.7 +querylog=$tmpdir/query.log
     1.8  
     1.9  tconfs=""
    1.10  imgcached=cache/img.`date +%Y/%m`
    1.11 @@ -333,14 +334,19 @@
    1.12    rm -f $sqo $sqi
    1.13    rm -rf $tmpfiles
    1.14  }
    1.15 +# We want to use piped function to put querylog, but we use
    1.16 +# simple redirection for the sake of speed.
    1.17  query() {
    1.18    echo ".once $sqo" >&5
    1.19 +  echo "`date`:[${user:-NULL}] <<<" >> $querylog
    1.20    if [ -z "$1" ]; then
    1.21 -    cat
    1.22 +    tee -a $querylog
    1.23    else
    1.24 +    echo "$@" >> $querylog
    1.25      echo "$@"
    1.26 -  fi >&5
    1.27 +  fi  >&5
    1.28    cat $sqo
    1.29 +  echo '>>>' >> $querylog
    1.30  }
    1.31  _m4() {
    1.32    #_S4NAME_=f,f,f