82 lines
1.8 KiB
Go
82 lines
1.8 KiB
Go
package thinkingdata
|
|
|
|
import (
|
|
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/global"
|
|
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/key"
|
|
"mongo.games.com/game/gamesrv/slotspkg/internal/module/shared"
|
|
)
|
|
|
|
const (
|
|
TrackType = "track"
|
|
TrackUpdateType = "track_update"
|
|
TrackOverwriteType = "track_overwrite"
|
|
UserSetType = "user_set"
|
|
UserUnsetType = "user_unset"
|
|
UserSetOnceType = "user_setOnce"
|
|
UserAddType = "user_add"
|
|
UserAppendType = "user_append"
|
|
UserDelType = "user_del"
|
|
)
|
|
|
|
func Track(ctx *shared.LogContext, v interface{}) {
|
|
if global.Mock {
|
|
return
|
|
}
|
|
formatEvent(ctx, TrackType, v)
|
|
}
|
|
|
|
func TrackUpdate(ctx *shared.LogContext, v interface{}) {
|
|
formatEvent(ctx, TrackUpdateType, v)
|
|
}
|
|
|
|
func TrackOverWrite(ctx *shared.LogContext, v interface{}) {
|
|
formatEvent(ctx, TrackOverwriteType, v)
|
|
}
|
|
|
|
func UserSet(ctx *shared.LogContext, v interface{}) {
|
|
formatUser(ctx, UserSetType, v)
|
|
}
|
|
|
|
func UserUnset(ctx *shared.LogContext, v interface{}) {
|
|
formatUser(ctx, UserUnsetType, v)
|
|
}
|
|
|
|
func UserSetOnce(ctx *shared.LogContext, v interface{}) {
|
|
formatUser(ctx, UserSetOnceType, v)
|
|
}
|
|
|
|
func UserAdd(ctx *shared.LogContext, v interface{}) {
|
|
formatUser(ctx, UserAddType, v)
|
|
}
|
|
|
|
func UserAppend(ctx *shared.LogContext, v interface{}) {
|
|
formatUser(ctx, UserAppendType, v)
|
|
}
|
|
|
|
func UserDel(ctx *shared.LogContext, v interface{}) {
|
|
formatUser(ctx, UserDelType, v)
|
|
}
|
|
|
|
func safeCtx(ctx *shared.LogContext) *shared.LogContext {
|
|
if ctx == nil {
|
|
identifier := &shared.Identifier{
|
|
ContextType: key.LogContextTypeNil,
|
|
LogType: key.LogTypeProcess,
|
|
GroupID: "",
|
|
BatchID: global.ProcessID,
|
|
ProcessID: global.ProcessID,
|
|
}
|
|
|
|
srv := &shared.Srv{
|
|
Runtime: global.Runtime,
|
|
Cluster: global.Cluster,
|
|
}
|
|
|
|
return &shared.LogContext{
|
|
Identifier: identifier,
|
|
Srv: srv,
|
|
}
|
|
}
|
|
return ctx
|
|
}
|