diff --git a/tglog.go b/tglog.go index f0199ca..cbef632 100644 --- a/tglog.go +++ b/tglog.go @@ -24,7 +24,7 @@ type tgLog struct { func (this *tgLog) init() { this.chGoSaveExit = make(chan int) - //go this.goSaveToFile() + go this.goSaveToFile() } func (this *tgLog) unInit() { @@ -41,10 +41,9 @@ func (this *tgLog) AddTrackLog( remoteAddr string, logClass1 int32, logClass2 int32, - //prop *q5.XObject) { - ) { - //eventName := fmt.Sprintf("event_%d_%d", logClass1, logClass2) - //this.AddTrackLogEx(gameId, accountId, remoteAddr, eventName, prop) + prop map[string]string) { + eventName := fmt.Sprintf("event_%d_%d", logClass1, logClass2) + this.AddTrackLogEx(gameId, accountId, remoteAddr, eventName, prop) } func (this *tgLog) AddTrackLogEx( @@ -52,20 +51,25 @@ func (this *tgLog) AddTrackLogEx( accountId string, remoteAddr string, eventName string, - //prop *q5.XObject) { -) { - /*xobj := q5.NewMxoObject() - xobj.SetXValue("#account_id", q5.NewXString(accountId)) - xobj.SetXValue("#type", q5.NewXString("track")) - xobj.SetXValue("#time", q5.NewXString(time.Now().Format("2006-01-02 15:04:05"))) - xobj.SetXValue("#event_name", q5.NewXString(eventName)) - xobj.SetXValue("#ip", q5.NewXString(remoteAddr)) - - xobj.SetXObject("properties", prop) - + prop map[string]string) { + logObj := struct { + AccountId string `json:"#account_id"` + Type string `json:"#type""` + Time string `json:"#time"` + EventName string `json:"#event_name""` + Ip string `json:"#ip""` + Properties map[string]string `json:"properties"` + } { + AccountId: accountId, + Type: "track", + Time: time.Now().Format("2006-01-02 15:04:05"), + EventName: eventName, + Ip: remoteAddr, + Properties: prop, + } p := new(tgLogMsgNode) p.gameId = gameId - p.jsonStr = xobj.ToJsonStr() + p.jsonStr = q5.EncodeJson(logObj) this.msgMutex.Lock() defer this.msgMutex.Unlock() if this.botNode != nil { @@ -75,7 +79,6 @@ func (this *tgLog) AddTrackLogEx( this.topNode = p this.botNode = p } - */ } func (this *tgLog) goSaveToFile() {