diff s4-funcs.sh @ 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
line wrap: on
line diff
--- a/s4-funcs.sh	Thu Oct 27 17:05:36 2016 +0859
+++ b/s4-funcs.sh	Thu Oct 27 21:22:27 2016 +0859
@@ -31,6 +31,7 @@
 ### maximagexy=400x400
 file_accept='accept="image/*,text/*,audio/*,application/vnd.oasis.*,application/pdf,application/x-*"'
 blogreadflagrowid=0
+querylog=$tmpdir/query.log
 
 tconfs=""
 imgcached=cache/img.`date +%Y/%m`
@@ -333,14 +334,19 @@
   rm -f $sqo $sqi
   rm -rf $tmpfiles
 }
+# We want to use piped function to put querylog, but we use
+# simple redirection for the sake of speed.
 query() {
   echo ".once $sqo" >&5
+  echo "`date`:[${user:-NULL}] <<<" >> $querylog
   if [ -z "$1" ]; then
-    cat
+    tee -a $querylog
   else
+    echo "$@" >> $querylog
     echo "$@"
-  fi >&5
+  fi  >&5
   cat $sqo
+  echo '>>>' >> $querylog
 }
 _m4() {
   #_S4NAME_=f,f,f

yatex.org