/
log.go
50 lines (46 loc) · 1.17 KB
/
log.go
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
package service
import (
"fmt"
"go-common/app/interface/main/videoup/model/archive"
"go-common/library/log"
"go-common/library/queue/databus/report"
"net"
"strconv"
"time"
)
// SendArchiveLog send to log service
func (s *Service) SendArchiveLog(aid int64, build, buvid, action, platform string, ap *archive.ArcParam, videoerr error) {
var (
LogType = archive.LogTypeSuccess
index = []interface{}{ap.TypeID, ap.UpFrom, ap.OrderID, ap.Title, ap.BizFrom, strconv.Itoa(ap.MissionID), fmt.Sprint(videoerr)}
)
if videoerr != nil {
LogType = archive.LogTypeFail
}
buildNum, _ := strconv.Atoi(build)
ip := net.IP(ap.IPv6[:]).String()
uInfo := &report.UserInfo{
Mid: ap.Mid,
Platform: platform,
Build: int64(buildNum),
Buvid: buvid,
Business: archive.ArchiveAddLogID,
Type: LogType,
Oid: aid,
Action: action,
Ctime: time.Now(),
Index: index,
IP: ip,
}
ap.Aid = aid
// es 最多存32k,我们日志就最多记100p吧
if len(ap.Videos) > 100 {
ap.Videos = ap.Videos[:100]
}
uInfo.Content = map[string]interface{}{
"content": ap,
"errmsg": videoerr,
}
report.User(uInfo)
log.Info("sendLog data(%+v)", uInfo)
}