stack.go
2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package utils
import (
"World/conf"
"common/logger"
stat "common/statistic"
"fmt"
"runtime"
"time"
"github.com/go-spew/spew"
)
// 产生panic时的调用栈打印
func PrintPanicStack(extras ...interface{}) {
if x := recover(); x != nil {
logger.Info("panic recover stack : %+v", x)
i := 0
funcName, file, line, ok := runtime.Caller(i)
for ok {
logger.Info("frame %v:[func:%v,file:%v,line:%v]\n", i, runtime.FuncForPC(funcName).Name(), file, line)
i++
funcName, file, line, ok = runtime.Caller(i)
}
for k := range extras {
logger.Info("EXRAS#%v DATA:%v\n", k, spew.Sdump(extras[k]))
}
}
}
func SendCurrencyReport(uid uint32, clubid uint32, change_channel, currency_type uint32, change_amount, param1, param2, param3 int, desc string) {
var report stat.CurrencyReport
report.ChangeTime = uint32(time.Now().Unix())
report.SourceType = conf.GetSourceType()
report.Uid = uid
if clubid > 0 {
report.ClubId = uint32(clubid)
}
report.ChangeChannel = change_channel
report.CurrencyType = currency_type
report.ChangeAmount = change_amount
report.Param1 = param1
report.Param2 = param2
report.Param3 = param3
report.Desc = desc
cfg := conf.GetEventReportHttpAddrConf()
stat.UploadReport(cfg.Host+cfg.CurrencyUri, &report)
}
func SendEventReport(uid uint32, clubid uint32, event_type uint32, param1, param2, param3 int, desc string) {
var report stat.EventReport
report.EventTime = uint32(time.Now().Unix())
report.SourceType = conf.GetSourceType()
report.Uid = uid
if clubid > 0 {
report.ClubId = uint32(clubid)
}
report.EventType = event_type
report.Param1 = param1
report.Param2 = param2
report.Param3 = param3
report.Desc = desc
cfg := conf.GetEventReportHttpAddrConf()
stat.UploadReport(cfg.Host+cfg.EventUri, &report)
}
func SendFairPlayReport(reporter_id, rid uint32, clubid uint32, room_uuid, game_uuid uint64, uids []uint32, contact, detail string) {
var report stat.FairPlayReport
report.EventTime = uint32(time.Now().Unix())
report.SourceType = conf.GetSourceType()
report.Uid = reporter_id
if clubid > 0 {
report.ClubId = uint32(clubid)
}
report.RoomId = rid
report.RoomUuid = fmt.Sprintf("%+v", room_uuid)
report.GameUuid = fmt.Sprintf("%+v", game_uuid)
report.SuspectIds = getStringOfSlice(uids)
report.Contact = contact
report.Detail = detail
report.Status = 0
cfg := conf.GetEventReportHttpAddrConf()
stat.UploadReport(cfg.Host+cfg.FairPlayUri, &report)
}
func getStringOfSlice(ids []uint32) string {
s := ""
for _, id := range ids {
s += fmt.Sprintf("%d,", id)
}
return s
}
func SendDeviceInfoReport(uid uint32, host string, channel uint32, device_info string) {
var report stat.DeviceInfoRecord
report.EventTime = uint32(time.Now().Unix())
report.SourceType = conf.GetSourceType()
report.Uid = uid
report.Channel = channel
report.Host = host
report.DeviceInfo = device_info
cfg := conf.GetEventReportHttpAddrConf()
stat.UploadReport(cfg.Host+cfg.DeviceInfoUri, &report)
}