|
@@ -4,7 +4,7 @@ import (
|
|
"encoding/json"
|
|
"encoding/json"
|
|
"log"
|
|
"log"
|
|
"net/http"
|
|
"net/http"
|
|
- . "salesLeads/src/service/config"
|
|
|
|
|
|
+ . "salesLeads/src/config"
|
|
"sync"
|
|
"sync"
|
|
"time"
|
|
"time"
|
|
|
|
|
|
@@ -14,13 +14,13 @@ import (
|
|
"app.yhyue.com/moapp/jybase/go-xweb/xweb"
|
|
"app.yhyue.com/moapp/jybase/go-xweb/xweb"
|
|
)
|
|
)
|
|
|
|
|
|
-//日志过滤器
|
|
|
|
|
|
+// 日志过滤器
|
|
type logfilter struct {
|
|
type logfilter struct {
|
|
App *xweb.App
|
|
App *xweb.App
|
|
SessionName string
|
|
SessionName string
|
|
}
|
|
}
|
|
|
|
|
|
-//继承过滤器方法
|
|
|
|
|
|
+// 继承过滤器方法
|
|
func (l *logfilter) Do(w http.ResponseWriter, req *http.Request) bool {
|
|
func (l *logfilter) Do(w http.ResponseWriter, req *http.Request) bool {
|
|
req.Proto = util.GetIp(req)
|
|
req.Proto = util.GetIp(req)
|
|
session := l.App.SessionManager.Session(req, w)
|
|
session := l.App.SessionManager.Session(req, w)
|
|
@@ -30,7 +30,7 @@ func (l *logfilter) Do(w http.ResponseWriter, req *http.Request) bool {
|
|
return true
|
|
return true
|
|
}
|
|
}
|
|
|
|
|
|
-//定时保存日志
|
|
|
|
|
|
+// 定时保存日志
|
|
func SaveLogTask() {
|
|
func SaveLogTask() {
|
|
lock.Lock()
|
|
lock.Lock()
|
|
if len(arr) >= 1 {
|
|
if len(arr) >= 1 {
|
|
@@ -46,13 +46,13 @@ func SaveLogTask() {
|
|
time.AfterFunc(5*time.Minute, SaveLogTask)
|
|
time.AfterFunc(5*time.Minute, SaveLogTask)
|
|
}
|
|
}
|
|
|
|
|
|
-//内存缓存日志数量,超过此数量存库
|
|
|
|
|
|
+// 内存缓存日志数量,超过此数量存库
|
|
var nc = 500
|
|
var nc = 500
|
|
|
|
|
|
-//内存缓存日志map
|
|
|
|
|
|
+// 内存缓存日志map
|
|
var arr = make([]map[string]interface{}, 0)
|
|
var arr = make([]map[string]interface{}, 0)
|
|
|
|
|
|
-//对map的同步
|
|
|
|
|
|
+// 对map的同步
|
|
var lock sync.Mutex
|
|
var lock sync.Mutex
|
|
|
|
|
|
func addLog(l *logfilter, session *httpsession.Session, req *http.Request) {
|
|
func addLog(l *logfilter, session *httpsession.Session, req *http.Request) {
|