diff --git a/tglog.go b/tglog.go index cf2bb23..8257c7a 100644 --- a/tglog.go +++ b/tglog.go @@ -73,6 +73,44 @@ func (this *tgLog) AddTrackLog( } } +func (this *tgLog) AddCustomLog( + gameId int32, + accountId string, + distinctId string, + ip string, + eventName string, + prop map[string]interface{}) { + logObj := struct { + AccountId string `json:"#account_id"` + DistinctId string `json:"#distinct_id"` + Type string `json:"#type""` + Time string `json:"#time"` + Ip string `json:"#ip""` + EventName string `json:"#event_name""` + Properties map[string]interface{} `json:"properties"` + }{ + AccountId: accountId, + DistinctId: distinctId, + Type: "track", + Time: q5.FormatUnixDateTime(_app.GetRealSeconds(), _app.GetLocation()), + EventName: eventName, + Ip: ip, + Properties: prop, + } + p := new(tgLogMsgNode) + p.gameId = gameId + p.jsonStr = q5.EncodeJson(logObj) + this.msgMutex.Lock() + defer this.msgMutex.Unlock() + if this.botNode != nil { + this.botNode.next = p + this.botNode = p + } else { + this.topNode = p + this.botNode = p + } +} + func (this *tgLog) goSaveToFile() { var workNode *tgLogMsgNode for {