同步优化日志代码

This commit is contained in:
liwei1dao 2022-12-19 16:25:22 +08:00
parent 44002c8052
commit a499d81135
93 changed files with 923 additions and 456 deletions

View File

@ -10,7 +10,10 @@ var AllLevels = []Loglevel{
}
type (
Field struct {
Key string
Value interface{}
}
Fields map[string]interface{}
Ilogf interface {
Debugf(format string, args ...interface{})
@ -31,13 +34,13 @@ type (
Panicln(args ...interface{})
}
ILog interface {
Debug(msg string, args Fields)
Info(msg string, args Fields)
Print(msg string, args Fields)
Warn(msg string, args Fields)
Error(msg string, args Fields)
Fatal(msg string, args Fields)
Panic(msg string, args Fields)
Debug(msg string, args ...Field)
Info(msg string, args ...Field)
Print(msg string, args ...Field)
Warn(msg string, args ...Field)
Error(msg string, args ...Field)
Fatal(msg string, args ...Field)
Panic(msg string, args ...Field)
}
ILogger interface {
@ -77,23 +80,23 @@ func NewSys(opt ...Option) (sys ISys, err error) {
func Clone(name string, skip int) ILogger {
return defsys.Clone(name, skip)
}
func Debug(msg string, args Fields) {
defsys.Debug(msg, args)
func Debug(msg string, args ...Field) {
defsys.Debug(msg, args...)
}
func Info(msg string, args Fields) {
defsys.Info(msg, args)
func Info(msg string, args ...Field) {
defsys.Info(msg, args...)
}
func Warn(msg string, args Fields) {
defsys.Warn(msg, args)
func Warn(msg string, args ...Field) {
defsys.Warn(msg, args...)
}
func Error(msg string, args Fields) {
defsys.Error(msg, args)
func Error(msg string, args ...Field) {
defsys.Error(msg, args...)
}
func Fatal(msg string, args Fields) {
defsys.Fatal(msg, args)
func Fatal(msg string, args ...Field) {
defsys.Fatal(msg, args...)
}
func Panic(msg string, args Fields) {
defsys.Panic(msg, args)
func Panic(msg string, args ...Field) {
defsys.Panic(msg, args...)
}
func Debugf(format string, args ...interface{}) {
defsys.Debugf(format, args...)

View File

@ -14,7 +14,7 @@ var (
_cePool = sync.Pool{New: func() interface{} {
// Pre-allocate some space for cores.
return &Entry{
Data: make(map[string]interface{}),
Data: make([]Field, 6),
}
}}
)
@ -79,7 +79,7 @@ type Entry struct {
Caller EntryCaller
Time time.Time
Message string
Data Fields
Data []Field
Err string
}
@ -91,12 +91,15 @@ func (entry *Entry) reset() {
entry.Caller.Function = ""
entry.Caller.Stack = ""
entry.Err = ""
entry.Data = make(map[string]interface{})
entry.Data = make([]Field, 6)
}
func (entry *Entry) WithFields(fields Fields) {
func (entry *Entry) WithFields(fields ...Field) {
fieldErr := entry.Err
if len(fields) > len(entry.Data) {
entry.Data = append(entry.Data, make([]Field, len(fields)-len(entry.Data))...)
}
for k, v := range fields {
isErrField := false
if t := reflect.TypeOf(v); t != nil {

View File

@ -62,14 +62,14 @@ func (this *ConsoleFormatter) Format(config *EncoderConfig, entry *Entry) (*pool
isfirst = false
line.AppendString(entry.Message)
}
for k, v := range entry.Data {
for _, v := range entry.Data {
if !isfirst {
line.AppendString(config.ConsoleSeparator)
}
isfirst = false
line.AppendString(k)
line.AppendString(v.Key)
line.AppendString(":")
writetoline(line, v)
writetoline(line, v.Value)
}
if entry.Caller.Stack != "" && config.StacktraceKey != "" {

View File

@ -31,6 +31,7 @@ func newSys(options *Options) (sys *Logger, err error) {
sys = &Logger{
config: NewDefEncoderConfig(),
formatter: NewConsoleEncoder(),
name: options.Alias,
out: out,
level: options.Loglevel,
addCaller: options.ReportCaller,
@ -55,7 +56,7 @@ func (this *Logger) Clone(name string, skip int) ILogger {
return &Logger{
config: this.config,
formatter: this.formatter,
name: name,
name: fmt.Sprintf("%s:%s", this.name, name),
out: this.out,
level: this.level,
addCaller: this.addCaller,
@ -69,31 +70,31 @@ func (this *Logger) SetName(name string) {
func (this *Logger) Enabled(lvl Loglevel) bool {
return this.level.Enabled(lvl)
}
func (this *Logger) Debug(msg string, args Fields) {
this.Log(DebugLevel, msg, args)
func (this *Logger) Debug(msg string, args ...Field) {
this.Log(DebugLevel, msg, args...)
}
func (this *Logger) Info(msg string, args Fields) {
this.Log(InfoLevel, msg, args)
func (this *Logger) Info(msg string, args ...Field) {
this.Log(InfoLevel, msg, args...)
}
func (this *Logger) Print(msg string, args Fields) {
this.Log(InfoLevel, msg, args)
func (this *Logger) Print(msg string, args ...Field) {
this.Log(InfoLevel, msg, args...)
}
func (this *Logger) Warn(msg string, args Fields) {
this.Log(WarnLevel, msg, args)
func (this *Logger) Warn(msg string, args ...Field) {
this.Log(WarnLevel, msg, args...)
}
func (this *Logger) Error(msg string, args Fields) {
this.Log(ErrorLevel, msg, args)
func (this *Logger) Error(msg string, args ...Field) {
this.Log(ErrorLevel, msg, args...)
}
func (this *Logger) Panic(msg string, args Fields) {
this.Log(PanicLevel, msg, args)
func (this *Logger) Panic(msg string, args ...Field) {
this.Log(PanicLevel, msg, args...)
}
func (this *Logger) Fatal(msg string, args Fields) {
this.Log(FatalLevel, msg, args)
func (this *Logger) Fatal(msg string, args ...Field) {
this.Log(FatalLevel, msg, args...)
os.Exit(1)
}
func (this *Logger) Log(level Loglevel, msg string, args Fields) {
func (this *Logger) Log(level Loglevel, msg string, args ...Field) {
if this.level.Enabled(level) {
this.logWithFields(level, msg, args)
this.logWithFields(level, msg, args...)
}
}
func (this *Logger) Debugf(format string, args ...interface{}) {
@ -151,8 +152,8 @@ func (this *Logger) Logln(level Loglevel, args ...interface{}) {
}
}
func (this *Logger) logWithFields(level Loglevel, msg string, args Fields) {
entry := this.checkWithFields(level, msg, args)
func (this *Logger) logWithFields(level Loglevel, msg string, args ...Field) {
entry := this.checkWithFields(level, msg, args...)
this.write(entry)
if level <= PanicLevel {
panic(entry)
@ -169,9 +170,9 @@ func (this *Logger) log(level Loglevel, msg string) {
putEntry(entry)
}
func (this *Logger) checkWithFields(level Loglevel, msg string, args Fields) (entry *Entry) {
func (this *Logger) checkWithFields(level Loglevel, msg string, args ...Field) (entry *Entry) {
e := this.check(level, msg)
e.WithFields(args)
e.WithFields(args...)
return e
}

View File

@ -15,6 +15,7 @@ const (
type Option func(*Options)
type Options struct {
Alias string //日志别名
FileName string //日志文件名包含
Loglevel Loglevel //日志输出级别
IsDebug bool //是否是开发模式
@ -28,6 +29,13 @@ type Options struct {
Compress bool //是否压缩备份日志
}
///日志输出别名
func SetAlias(v string) Option {
return func(o *Options) {
o.Alias = v
}
}
///日志文件名包含
func SetFileName(v string) Option {
return func(o *Options) {

View File

@ -40,6 +40,6 @@ func Test_sys(t *testing.T) {
func Benchmark_Ability(b *testing.B) {
for i := 0; i < b.N; i++ { //use b.N for looping
// sys.Errorln("妈妈咪呀!")
sys.Error("测试", log.Fields{"a":1,"b":2})
sys.Error("测试", log.Field{Key: "a", Value: 1}, log.Field{Key: "b", Value: 2})
}
}

View File

@ -25,39 +25,39 @@ func (this *Turnlog) Enabled(lvl Loglevel) bool {
return false
}
}
func (this *Turnlog) Debug(msg string, args Fields) {
func (this *Turnlog) Debug(msg string, args ...Field) {
if this.isturnon && this.log != nil {
this.log.Debug(msg, args)
this.log.Debug(msg, args...)
}
}
func (this *Turnlog) Info(msg string, args Fields) {
func (this *Turnlog) Info(msg string, args ...Field) {
if this.isturnon && this.log != nil {
this.log.Info(msg, args)
this.log.Info(msg, args...)
}
}
func (this *Turnlog) Print(msg string, args Fields) {
func (this *Turnlog) Print(msg string, args ...Field) {
if this.isturnon && this.log != nil {
this.log.Print(msg, args)
this.log.Print(msg, args...)
}
}
func (this *Turnlog) Warn(msg string, args Fields) {
func (this *Turnlog) Warn(msg string, args ...Field) {
if this.isturnon && this.log != nil {
this.log.Warn(msg, args)
this.log.Warn(msg, args...)
}
}
func (this *Turnlog) Error(msg string, args Fields) {
func (this *Turnlog) Error(msg string, args ...Field) {
if this.log != nil {
this.log.Error(msg, args)
this.log.Error(msg, args...)
}
}
func (this *Turnlog) Panic(msg string, args Fields) {
func (this *Turnlog) Panic(msg string, args ...Field) {
if this.log != nil {
this.log.Panic(msg, args)
this.log.Panic(msg, args...)
}
}
func (this *Turnlog) Fatal(msg string, args Fields) {
func (this *Turnlog) Fatal(msg string, args ...Field) {
if this.log != nil {
this.log.Fatal(msg, args)
this.log.Fatal(msg, args...)
}
}
func (this *Turnlog) Debugf(format string, args ...interface{}) {

View File

@ -60,11 +60,12 @@ func (this *Selector) Select(ctx context.Context, servicePath, serviceMethod str
} else if leng == 2 {
result := this.ParseRoutRules(service[1])
if len(result) == 0 {
this.log.Error("Select no found any node", log.Fields{
"stag": this.stag,
"servicePath": servicePath,
"serviceMethod": serviceMethod,
"routrules": routrules})
this.log.Error("Select no found any node",
log.Field{Key: "stag", Value: this.stag},
log.Field{Key: "servicePath", Value: servicePath},
log.Field{Key: "serviceMethod", Value: serviceMethod},
log.Field{Key: "routrules", Value: routrules},
)
return ""
}
i := fastrand.Uint32n(uint32(len(result)))

View File

@ -69,14 +69,16 @@ func (this *Arena) OnInstallComp() {
//比赛结算
func (this *Arena) Rpc_ModuleArenaRaceSettlement(ctx context.Context, args *pb.EmptyReq, reply *pb.EmptyResp) (err error) {
this.Debug("Rpc_ModuleArenaRaceSettlement", log.Fields{"args": args.String()})
this.Debug("Rpc_ModuleArenaRaceSettlement",
log.Field{Key: "args", Value: args.String()},
)
this.modelRank.raceSettlement()
return
}
//修改用户积分
func (this *Arena) Rpc_ModuleArenaModifyIntegral(ctx context.Context, args *pb.RPCModifyIntegralReq, reply *pb.EmptyResp) (err error) {
this.Debug("Rpc_ModuleArenaModifyIntegral", log.Fields{"args": args.String()})
this.Debug("Rpc_ModuleArenaModifyIntegral", log.Field{Key: "args", Value: args.String()})
err = this.modelArena.modifyIntegral(args.Uid, args.Integral)
return
}

View File

@ -129,26 +129,26 @@ func (this *FightBase) Rand(min, max int32) int32 {
//Log-----------------------------------------------------------------------------------------------------------------------
//日志接口
func (this *FightBase) Debug(msg string, args log.Fields) {
this.options.Log.Debug(msg, args)
func (this *FightBase) Debug(msg string, args ...log.Field) {
this.options.Log.Debug(msg, args...)
}
func (this *FightBase) Info(msg string, args log.Fields) {
this.options.Log.Info(msg, args)
func (this *FightBase) Info(msg string, args ...log.Field) {
this.options.Log.Info(msg, args...)
}
func (this *FightBase) Print(msg string, args log.Fields) {
this.options.Log.Print(msg, args)
func (this *FightBase) Print(msg string, args ...log.Field) {
this.options.Log.Print(msg, args...)
}
func (this *FightBase) Warn(msg string, args log.Fields) {
this.options.Log.Warn(msg, args)
func (this *FightBase) Warn(msg string, args ...log.Field) {
this.options.Log.Warn(msg, args...)
}
func (this *FightBase) Error(msg string, args log.Fields) {
this.options.Log.Error(msg, args)
func (this *FightBase) Error(msg string, args ...log.Field) {
this.options.Log.Error(msg, args...)
}
func (this *FightBase) Panic(msg string, args log.Fields) {
this.options.Log.Panic(msg, args)
func (this *FightBase) Panic(msg string, args ...log.Field) {
this.options.Log.Panic(msg, args...)
}
func (this *FightBase) Fatal(msg string, args log.Fields) {
this.options.Log.Fatal(msg, args)
func (this *FightBase) Fatal(msg string, args ...log.Field) {
this.options.Log.Fatal(msg, args...)
}
func (this *FightBase) Debugf(format string, args ...interface{}) {

View File

@ -373,7 +373,9 @@ func (this *modelBattleComp) createMasterRoles(comp, wheel int, fid int32) (capt
} else {
hero := &pb.DBHero{}
if hero = this.module.ModuleHero.CreateMonster(monst.HeroId, monst.Star, v.Lv); hero == nil {
this.module.Error("on found battle req data", log.Fields{"HeroId": monst.HeroId})
this.module.Error("on found battle req data",
log.Field{Key: "HeroId", Value: monst.HeroId},
)
code = pb.ErrorCode_ReqParameterError
return
} else {

View File

@ -200,10 +200,17 @@ func (this *Battle) CheckBattleReport(session comm.IUserSession, report *pb.Batt
stime := time.Now()
if reply, err = this.clients.CheckBattle(context.Background(), report); err != nil || !reply.Ischeck {
code = pb.ErrorCode_BattleValidationFailed
this.Error("[Battle Check]", log.Fields{"t": time.Since(stime).Milliseconds(), "reply": reply.String()})
this.Error("[Battle Check]",
log.Field{Key: "t", Value: time.Since(stime).Milliseconds()},
log.Field{Key: "reply", Value: reply.String()},
log.Field{Key: "err", Value: err.Error()},
)
return
}
this.Debug("[Battle Check]", log.Fields{"t": time.Since(stime).Milliseconds(), "reply": reply.String()})
this.Debug("[Battle Check]",
log.Field{Key: "t", Value: time.Since(stime).Milliseconds()},
log.Field{Key: "reply", Value: reply.String()},
)
}
this.moonfantasy.Trigger(session, report)
return pb.ErrorCode_Success, true

View File

@ -82,7 +82,10 @@ func (this *Chat) OnInstallComp() {
//Event------------------------------------------------------------------------------------------------------------
func (this *Chat) EventUserOffline(session comm.IUserSession) {
if err := this.modelChat.removeCrossChannelMember(session); err != nil {
this.Debug("EventUserOffline:", log.Fields{"uid": session.GetUserId(), "err": err.Error()})
this.Debug("EventUserOffline:",
log.Field{Key: "uid", Value: session.GetUserId()},
log.Field{Key: "err", Value: err.Error()},
)
}
}

View File

@ -14,7 +14,7 @@ import (
func (this *apiComp) AddblackCheck(session comm.IUserSession, req *pb.FriendAddBlackReq) (code pb.ErrorCode) {
if req.FriendId == "" {
code = pb.ErrorCode_ReqParameterError
this.moduleFriend.Error("加入黑名单参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.moduleFriend.Error("加入黑名单参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
}
return
}
@ -81,7 +81,11 @@ func (this *apiComp) Addblack(session comm.IUserSession, req *pb.FriendAddBlackR
})
if err != nil {
code = pb.ErrorCode_DBError
this.moduleFriend.Error("加入黑名单", log.Fields{"uid": uid, "目标人": req.FriendId, "err": err.Error()})
this.moduleFriend.Error("加入黑名单",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "目标人", Value: req.FriendId},
log.Field{Key: "err", Value: err.Error()},
)
return
}

View File

@ -14,7 +14,7 @@ import (
func (this *apiComp) AgreeCheck(session comm.IUserSession, req *pb.FriendAgreeReq) (code pb.ErrorCode) {
if len(req.FriendIds) == 0 {
code = pb.ErrorCode_ReqParameterError
this.moduleFriend.Error("好友审批同意参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.moduleFriend.Error("好友审批同意参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
}
return
@ -61,9 +61,15 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.FriendAgreeReq) (c
},
}
this.moduleFriend.Debug("设置的助战英雄推送给好友", log.Fields{"uid": uid, "heroObjId": heroObjId})
this.moduleFriend.Debug("设置的助战英雄推送给好友",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "heroObjId", Value: heroObjId},
)
if err := this.moduleFriend.SendMsgToUsers(string(this.moduleFriend.GetType()), "assistheroupdate", push, friendId); err != nil {
this.moduleFriend.Error("推送助战英雄列表", log.Fields{"uid": uid, "err": err.Error()})
this.moduleFriend.Error("推送助战英雄列表",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "err", Value: err.Error()},
)
}
}
@ -96,7 +102,11 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.FriendAgreeReq) (c
"friendIds": target.FriendIds,
}); err != nil {
code = pb.ErrorCode_DBError
this.moduleFriend.Error("好友审批同意", log.Fields{"uid": uid, "params": req.FriendIds, "err": err.Error()})
this.moduleFriend.Error("好友审批同意",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "params", Value: req.FriendIds},
log.Field{Key: "err", Value: err.Error()},
)
return
}

View File

@ -14,7 +14,7 @@ import (
func (this *apiComp) ApplyCheck(session comm.IUserSession, req *pb.FriendApplyReq) (code pb.ErrorCode) {
if req.FriendId == "" {
code = pb.ErrorCode_ReqParameterError
this.moduleFriend.Error("好友申请参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.moduleFriend.Error("好友申请参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
}
return
}
@ -99,7 +99,11 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.FriendApplyReq) (c
"applyIds": target.ApplyIds,
}); err != nil {
code = pb.ErrorCode_FriendApplyError
this.moduleFriend.Error("好友申请", log.Fields{"uid": uid, "params": req.FriendId, "err": err.Error()})
this.moduleFriend.Error("好友申请",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "params", Value: req.FriendId},
log.Field{Key: "err", Value: err.Error()},
)
return
}

View File

@ -14,7 +14,7 @@ import (
func (this *apiComp) AssistheroCheck(session comm.IUserSession, req *pb.FriendAssistheroReq) (code pb.ErrorCode) {
if req.HeroObjId == "" {
code = pb.ErrorCode_ReqParameterError
this.moduleFriend.Error("设置助战英雄参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.moduleFriend.Error("设置助战英雄参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
}
return
}
@ -28,7 +28,11 @@ func (this *apiComp) Assisthero(session comm.IUserSession, req *pb.FriendAssisth
hero, err := this.moduleFriend.ModuleHero.QueryCrossHeroinfo(req.HeroObjId)
if err != nil {
code = pb.ErrorCode_DBError
this.moduleFriend.Error("查询英雄数据 QueryCrossHeroinfo", log.Fields{"uid": uid, "param": req.HeroObjId, "err": err.Error()})
this.moduleFriend.Error("查询英雄数据 QueryCrossHeroinfo",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "params", Value: req.HeroObjId},
log.Field{Key: "err", Value: err.Error()},
)
return
}
@ -56,7 +60,11 @@ func (this *apiComp) Assisthero(session comm.IUserSession, req *pb.FriendAssisth
if err := this.moduleFriend.modelFriend.Change(self.Uid, update); err != nil {
code = pb.ErrorCode_FriendApplyError
this.moduleFriend.Error("设置助战英雄", log.Fields{"uid": uid, "param": req.HeroObjId, "err": err.Error()})
this.moduleFriend.Error("设置助战英雄",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "params", Value: req.HeroObjId},
log.Field{Key: "err", Value: err.Error()},
)
return
}
@ -76,9 +84,17 @@ func (this *apiComp) Assisthero(session comm.IUserSession, req *pb.FriendAssisth
},
}
this.moduleFriend.Debug("设置的助战英雄推送给好友", log.Fields{"uid": uid, "friendIds": self.FriendIds, "heroObjId": req.HeroObjId})
this.moduleFriend.Debug("设置的助战英雄推送给好友",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "friendIds", Value: self.FriendIds},
log.Field{Key: "heroObjId", Value: req.HeroObjId},
)
if err := this.moduleFriend.SendMsgToUsers(string(this.moduleFriend.GetType()), "assistheroupdate", push, self.FriendIds...); err != nil {
this.moduleFriend.Error("推送助战英雄列表", log.Fields{"uid": uid, "friends": self.FriendIds, "err": err.Error()})
this.moduleFriend.Error("推送助战英雄列表",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "friends", Value: self.FriendIds},
log.Field{Key: "err", Value: err.Error()},
)
}
}

View File

@ -13,7 +13,7 @@ import (
func (this *apiComp) DelCheck(session comm.IUserSession, req *pb.FriendDelReq) (code pb.ErrorCode) {
if req.FriendId == "" {
code = pb.ErrorCode_ReqParameterError
this.moduleFriend.Error("删除好友参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.moduleFriend.Error("删除好友参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
}
return
}
@ -36,7 +36,11 @@ func (this *apiComp) Del(session comm.IUserSession, req *pb.FriendDelReq) (code
if err := this.moduleFriend.modelFriend.Change(self.Uid, map[string]interface{}{
"friendIds": selfFriendIds,
}); err != nil {
this.moduleFriend.Error("删除好友", log.Fields{"uid": uid, "params": req, "err": err.Error()})
this.moduleFriend.Error("删除好友",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "params", Value: req.String()},
log.Field{Key: "err", Value: err.Error()},
)
code = pb.ErrorCode_FriendApplyError
return
}
@ -54,7 +58,11 @@ func (this *apiComp) Del(session comm.IUserSession, req *pb.FriendDelReq) (code
"friendIds": targetFriendIds,
}); err != nil {
code = pb.ErrorCode_FriendApplyError
this.moduleFriend.Error("删除好友", log.Fields{"uid": uid, "param": req.FriendId, "err": err.Error()})
this.moduleFriend.Error("删除好友",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "params", Value: req.FriendId},
log.Field{Key: "err", Value: err.Error()},
)
return
}

View File

@ -13,7 +13,7 @@ import (
func (this *apiComp) DelblackCheck(session comm.IUserSession, req *pb.FriendDelBlackReq) (code pb.ErrorCode) {
if req.FriendId == "" {
code = pb.ErrorCode_ReqParameterError
this.moduleFriend.Error("参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.moduleFriend.Error("参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
}
return
}
@ -40,7 +40,10 @@ func (this *apiComp) Delblack(session comm.IUserSession, req *pb.FriendDelBlackR
"blackIds": self.BlackIds,
}); err != nil {
code = pb.ErrorCode_DBError
this.moduleFriend.Error("删除黑名单", log.Fields{"uid": uid, "err": err.Error()})
this.moduleFriend.Error("删除黑名单",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "err", Value: err.Error()},
)
return
}

View File

@ -13,7 +13,7 @@ import (
func (this *apiComp) GetRelationCheck(session comm.IUserSession, req *pb.FriendGetRelationReq) (code pb.ErrorCode) {
if req.TargetUid == "" {
code = pb.ErrorCode_ReqParameterError
this.moduleFriend.Error("参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.moduleFriend.Error("参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
}
return
}

View File

@ -33,13 +33,20 @@ func (this *apiComp) Getreward(session comm.IUserSession, req *pb.FriendGetrewar
}
if err := this.moduleFriend.modelFriend.Change(self.Uid, update); err != nil {
code = pb.ErrorCode_FriendApplyError
this.moduleFriend.Error("领奖", log.Fields{"uid": uid, "err": err.Error()})
this.moduleFriend.Error("领奖",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "err", Value: err.Error()},
)
return
}
globalConf := this.moduleFriend.configure.GetGlobalConf()
if code = this.moduleFriend.DispenseRes(session, globalConf.FriendPeize, true); code != pb.ErrorCode_Success {
this.moduleFriend.Error("好友领奖励", log.Fields{"uid": uid, "reward": globalConf.FriendPeize, "code": code})
this.moduleFriend.Error("好友领奖励",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "reward", Value: globalConf.FriendPeize},
log.Field{Key: "code", Value: code},
)
return
}

View File

@ -13,7 +13,7 @@ import (
func (this *apiComp) RefuseCheck(session comm.IUserSession, req *pb.FriendRefuseReq) (code pb.ErrorCode) {
if len(req.FriendIds) == 0 {
code = pb.ErrorCode_ReqParameterError
this.moduleFriend.Error("参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.moduleFriend.Error("参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
}
return
@ -57,7 +57,11 @@ func (this *apiComp) Refuse(session comm.IUserSession, req *pb.FriendRefuseReq)
"applyIds": self.ApplyIds,
}); err != nil {
code = pb.ErrorCode_DBError
this.moduleFriend.Error("好友审批拒绝", log.Fields{"uid": uid, "params": req, "err": err.Error()})
this.moduleFriend.Error("好友审批拒绝",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "params", Value: req},
log.Field{Key: "err", Value: err.Error()},
)
return
}
}

View File

@ -13,7 +13,7 @@ import (
func (this *apiComp) SearchCheck(session comm.IUserSession, req *pb.FriendSearchReq) (code pb.ErrorCode) {
if req.NickName == "" {
code = pb.ErrorCode_FriendSearchNameEmpty
this.moduleFriend.Error("参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.moduleFriend.Error("参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
return
}
return
@ -30,7 +30,11 @@ func (this *apiComp) Search(session comm.IUserSession, req *pb.FriendSearchReq)
users, err := this.moduleFriend.ModuleUser.SearchRmoteUser(req.NickName)
if err != nil {
code = pb.ErrorCode_DBError
this.moduleFriend.Error("搜索玩家", log.Fields{"uid": uid, "params": req.NickName, "err": err.Error()})
this.moduleFriend.Error("搜索玩家",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "params", Value: req.NickName},
log.Field{Key: "err", Value: err.Error()},
)
return
}
@ -52,7 +56,7 @@ func (this *apiComp) Search(session comm.IUserSession, req *pb.FriendSearchReq)
continue
}
if _, ok := utils.Findx(target.ApplyIds,uid); ok {
if _, ok := utils.Findx(target.ApplyIds, uid); ok {
base.IsApplied = true
}
resp.Friends = append(resp.Friends, base)

View File

@ -13,7 +13,7 @@ import (
func (this *apiComp) ZanCheck(session comm.IUserSession, req *pb.FriendZanReq) (code pb.ErrorCode) {
if len(req.FriendIds) == 0 {
code = pb.ErrorCode_ReqParameterError
this.moduleFriend.Error("参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.moduleFriend.Error("参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
}
return
}
@ -61,7 +61,10 @@ func (this *apiComp) Zan(session comm.IUserSession, req *pb.FriendZanReq) (code
"getZandIds": target.GetZandIds,
}); err != nil {
code = pb.ErrorCode_DBError
this.moduleFriend.Error("点赞", log.Fields{"uid": uid, "err": err.Error()})
this.moduleFriend.Error("点赞",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "err", Value: err.Error()},
)
return
}
}

View File

@ -14,7 +14,7 @@ import (
func (this *apiComp) ZanreceiveCheck(session comm.IUserSession, req *pb.FriendZanreceiveReq) (code pb.ErrorCode) {
if len(req.FriendIds) == 0 {
code = pb.ErrorCode_ReqParameterError
this.moduleFriend.Error("参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.moduleFriend.Error("参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
}
return
}
@ -42,7 +42,7 @@ func (this *apiComp) Zanreceive(session comm.IUserSession, req *pb.FriendZanrece
// 是否已领取点赞
for _, v := range req.FriendIds {
if _, ok := utils.Find(self.GetZandIds, v); ok {
self.GetZandIds = utils.Deletex(self.GetZandIds,v)
self.GetZandIds = utils.Deletex(self.GetZandIds, v)
pointTotal += 1
}
}

View File

@ -74,7 +74,7 @@ func (this *Friend) ResetFriend(uid string) {
"received": 0, //奖励状态重置
}
if err := this.modelFriend.Change(uid, zanUpdate); err != nil {
log.Error("重置玩家点赞数据", log.Fields{"uid": uid, "err": err})
log.Error("重置玩家点赞数据", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err})
}
// 重置今日友情点
@ -83,7 +83,7 @@ func (this *Friend) ResetFriend(uid string) {
"friendPointOD": 0,
}
if err := this.ModuleUser.ChangeUserExpand(uid, update); err != nil {
log.Error("重置今日友情点", log.Fields{"uid": uid, "err": err})
log.Error("重置今日友情点", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err})
}
}
@ -103,7 +103,7 @@ func (this *Friend) GetFriendList(uid string) (uids []string) {
}
func (this *Friend) RpcUseAssisHero(ctx context.Context, req *pb.RPCGeneralReqA2, reply *pb.DBHero) error {
this.Debug("Rpc_ModuleFriendUseAssitHero", log.Fields{"req": req})
this.Debug("Rpc_ModuleFriendUseAssitHero", log.Field{Key: "req", Value: req.String()})
hero, err := this.UseAssistHero(req.Param1, req.Param2)
if err != nil {
return err
@ -113,7 +113,7 @@ func (this *Friend) RpcUseAssisHero(ctx context.Context, req *pb.RPCGeneralReqA2
}
func (this *Friend) RpcFriendDB(ctx context.Context, req *pb.RPCGeneralReqA1, reply *pb.DBFriend) error {
this.Debug("Rpc_ModuleFriendDB", log.Fields{"req": req})
this.Debug("Rpc_ModuleFriendDB", log.Field{Key: "req", Value: req.String()})
friend := &pb.DBFriend{Uid: req.Param1}
err := this.modelFriend.Get(req.Param1, friend)
if err != nil {
@ -146,7 +146,11 @@ func (this *Friend) UseAssistHero(uid, friendId string) (*pb.DBHero, error) {
for _, r := range friend.Record {
if r.AssistHeroId == friend.AssistHeroId {
if utils.IsToday(r.AssistTime) {
log.Warn("今日已助战", log.Fields{"uid": uid, "friendId": friend, "assistHeroId": r.AssistHeroId})
log.Warn("今日已助战",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "friendId", Value: friend},
log.Field{Key: "assistHeroId", Value: r.AssistHeroId},
)
return nil, errors.New("今日已助战")
}
}

View File

@ -283,20 +283,32 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) (err error) {
if len(serviceTag) == 0 {
if err = this.gateway.Service().RpcCall(context.Background(), servicePath, string(comm.Rpc_GatewayRoute), req, reply); err != nil {
this.gateway.Error("[UserResponse]",
log.Fields{"uid": this.uId, "serviceTag": serviceTag, "servicePath": servicePath, "req": req.String(), "err": err.Error()},
log.Field{Key: "uid", Value: this.uId},
log.Field{Key: "serviceTag", Value: serviceTag},
log.Field{Key: "servicePath", Value: servicePath},
log.Field{Key: "servicePath", Value: servicePath},
log.Field{Key: "req", Value: req.String()},
log.Field{Key: "err", Value: err.Error()},
)
return
}
} else { //跨集群调用
if err = this.gateway.Service().AcrossClusterRpcCall(context.Background(), serviceTag, servicePath, string(comm.Rpc_GatewayRoute), req, reply); err != nil {
this.gateway.Error("[UserResponse]",
log.Fields{"uid": this.uId, "serviceTag": serviceTag, "servicePath": servicePath, "req": req.String(), "err": err.Error()},
log.Field{Key: "uid", Value: this.uId},
log.Field{Key: "serviceTag", Value: serviceTag},
log.Field{Key: "servicePath", Value: servicePath},
log.Field{Key: "req", Value: req.String()},
log.Field{Key: "err", Value: err.Error()},
)
return
}
}
this.gateway.Debug("[UserResponse]",
log.Fields{"uid": this.uId, "t": time.Since(stime).Milliseconds(), "req": req.String(), "reply": reply.String()},
log.Field{Key: "t", Value: time.Since(stime).Milliseconds()},
log.Field{Key: "uid", Value: this.uId},
log.Field{Key: "req", Value: req.String()},
log.Field{Key: "reply", Value: reply.String()},
)
if reply.Code != pb.ErrorCode_Success {
data, _ := anypb.New(&pb.NotifyErrorNotifyPush{

View File

@ -125,26 +125,26 @@ func (this *Gateway) SetName(name string) {
}
//日志接口
func (this *Gateway) Debug(msg string, args log.Fields) {
this.options.GetLog().Debug(msg, args)
func (this *Gateway) Debug(msg string, args ...log.Field) {
this.options.GetLog().Debug(msg, args...)
}
func (this *Gateway) Info(msg string, args log.Fields) {
this.options.GetLog().Info(msg, args)
func (this *Gateway) Info(msg string, args ...log.Field) {
this.options.GetLog().Info(msg, args...)
}
func (this *Gateway) Print(msg string, args log.Fields) {
this.options.GetLog().Print(msg, args)
func (this *Gateway) Print(msg string, args ...log.Field) {
this.options.GetLog().Print(msg, args...)
}
func (this *Gateway) Warn(msg string, args log.Fields) {
this.options.GetLog().Warn(msg, args)
func (this *Gateway) Warn(msg string, args ...log.Field) {
this.options.GetLog().Warn(msg, args...)
}
func (this *Gateway) Error(msg string, args log.Fields) {
this.options.GetLog().Error(msg, args)
func (this *Gateway) Error(msg string, args ...log.Field) {
this.options.GetLog().Error(msg, args...)
}
func (this *Gateway) Panic(msg string, args log.Fields) {
this.options.GetLog().Panic(msg, args)
func (this *Gateway) Panic(msg string, args ...log.Field) {
this.options.GetLog().Panic(msg, args...)
}
func (this *Gateway) Fatal(msg string, args log.Fields) {
this.options.GetLog().Fatal(msg, args)
func (this *Gateway) Fatal(msg string, args ...log.Field) {
this.options.GetLog().Fatal(msg, args...)
}
func (this *Gateway) Debugf(format string, args ...interface{}) {

View File

@ -85,7 +85,12 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC
if code == pb.ErrorCode_Success { // 成功直接返回
session.SendMsg(string(this.GetType()), "cmd", &pb.GMCmdResp{IsSucc: true})
}
this.Debug("使用bingo命令", log.Fields{"uid": session.GetUserId(), "A": datas[0], "T": datas[1], "N": int32(num)})
this.Debug("使用bingo命令",
log.Field{Key: "uid", Value: session.GetUserId()},
log.Field{Key: "A", Value: datas[0]},
log.Field{Key: "T", Value: datas[1]},
log.Field{Key: "N", Value: int32(num)},
)
} else if len(datas) == 2 && (datas[0] == "mapid") {
module1, err := this.service.GetModule(comm.ModuleMainline)
if err != nil {
@ -98,7 +103,11 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC
}
code = module1.(comm.IMainline).ModifyMainlineData(session.GetUserId(), int32(num))
this.Debug("使用bingo命令", log.Fields{"uid": session.GetUserId(), "0": datas[0], "N": int32(num)})
this.Debug("使用bingo命令",
log.Field{Key: "uid", Value: session.GetUserId()},
log.Field{Key: "0", Value: datas[0]},
log.Field{Key: "N", Value: int32(num)},
)
} else if len(datas) == 2 && (datas[0] == "pataid") {
module1, err := this.service.GetModule(comm.ModulePagoda)
if err != nil {
@ -110,7 +119,11 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC
return
}
code = module1.(comm.IPagoda).ModifyPagodaFloor(session, int32(num))
this.Debug("使用bingo命令:uid = %s ", log.Fields{"uid": session.GetUserId(), "0": datas[0], "N": int32(num)})
this.Debug("使用bingo命令:uid = %s ",
log.Field{Key: "uid", Value: session.GetUserId()},
log.Field{Key: "0", Value: datas[0]},
log.Field{Key: "N", Value: int32(num)},
)
} else if len(datas) == 1 && (datas[0] == "Iamyoudad" || datas[0] == "iamyoudad") {
var (
res []*cfg.Gameatn
@ -135,7 +148,11 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC
this.Errorf("资源发放失败,%v", code)
}
}
this.Debug("使用bingo命令", log.Fields{"uid": session.GetUserId(), "param": datas[0], "res": res})
this.Debug("使用bingo命令",
log.Field{Key: "uid", Value: session.GetUserId()},
log.Field{Key: "param", Value: datas[0]},
log.Field{Key: "res", Value: res},
)
} else if len(datas) == 3 && (datas[0] == "worldtask") {
module, err := this.service.GetModule(comm.ModuleWorldtask)
if err != nil {
@ -143,7 +160,10 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC
}
if wt, ok := module.(comm.IWorldtask); ok {
if err = wt.BingoJumpTask(session, utils.ToInt32(datas[1]), utils.ToInt32(datas[2])); err != nil {
this.Error("bingo 世界任务", log.Fields{"params": datas, "err": err.Error()})
this.Error("bingo 世界任务",
log.Field{Key: "params", Value: datas},
log.Field{Key: "err", Value: err.Error()},
)
}
}
} else if len(datas) == 1 && (datas[0] == "manhero") { // 获取满星、等级、觉醒、共鸣技能
@ -153,7 +173,10 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC
}
code = module1.(comm.IHero).GetAllMaxHero(session)
this.Debug("使用bingo命令:uid = %s ", log.Fields{"uid": session.GetUserId(), "0": datas[1]})
this.Debug("使用bingo命令:uid = %s ",
log.Field{Key: "uid", Value: session.GetUserId()},
log.Field{Key: "0", Value: datas[1]},
)
} else if len(datas) == 2 && (datas[0] == "season") { // 赛季塔跳转
module1, err := this.service.GetModule(comm.ModulePagoda)
if err != nil {
@ -165,7 +188,11 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC
return
}
code = module1.(comm.IPagoda).ModifySeasonPagodaFloor(session, int32(num))
this.Debug("使用bingo命令:uid = %s ", log.Fields{"uid": session.GetUserId(), "0": datas[0], "N": int32(num)})
this.Debug("使用bingo命令:uid = %s ",
log.Field{Key: "uid", Value: session.GetUserId()},
log.Field{Key: "0", Value: datas[0]},
log.Field{Key: "N", Value: int32(num)},
)
} else if len(datas) == 1 && (datas[0] == "viking") { // 解锁远征所有难度
module1, err := this.service.GetModule(comm.ModuleViking)
if err != nil {
@ -173,7 +200,7 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC
}
code = module1.(comm.IViking).CompleteAllLevel(session)
this.Debug("使用bingo命令:uid = %s ", log.Fields{"uid": session.GetUserId()})
this.Debug("使用bingo命令:uid = %s ", log.Field{Key: "uid", Value: session.GetUserId()})
} else if len(datas) == 1 && (datas[0] == "hunting") { // 解锁狩猎所有难度
module1, err := this.service.GetModule(comm.ModuleHunting)
if err != nil {
@ -181,7 +208,9 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC
}
code = module1.(comm.IHunting).CompleteAllLevel(session)
this.Debug("使用bingo命令:uid = %s ", log.Fields{"uid": session.GetUserId(), "0": datas[1]})
this.Debug("使用bingo命令:uid = %s ",
log.Field{Key: "uid", Value: session.GetUserId()},
log.Field{Key: "0", Value: datas[1]})
} else if len(datas) == 3 && (datas[0] == "mainline") {
module1, err := this.service.GetModule(comm.ModuleMainline)
if err != nil {
@ -199,7 +228,10 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC
}
code = module1.(comm.IMainline).ModifyMainlineDataByNanduID(session.GetUserId(), int32(num1), int32(num2))
this.Debug("使用bingo命令", log.Fields{"uid": session.GetUserId(), "key:": keys[1]})
this.Debug("使用bingo命令",
log.Field{Key: "uid", Value: session.GetUserId()},
log.Field{Key: "0", Value: datas[1]},
)
} else if len(datas) == 2 && (datas[0] == "moon") { // 触发月之秘境
module1, err := this.service.GetModule(comm.ModuleMoonfantasy)
if err != nil {
@ -208,7 +240,10 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC
module1.(comm.IMoonFantasy).TriggerMF(session, datas[1])
code = pb.ErrorCode_Success
this.Debug("使用bingo命令", log.Fields{"uid": session.GetUserId(), "0": datas[1]})
this.Debug("使用bingo命令",
log.Field{Key: "uid", Value: session.GetUserId()},
log.Field{Key: "0", Value: datas[1]},
)
code = pb.ErrorCode_Success
} else if len(datas) == 2 && (datas[0] == "arena") { // 设置竞技场用户积分
module1, err := this.service.GetModule(comm.ModuleArena)
@ -222,7 +257,10 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC
}
module1.(comm.IArena).SetUserIntegral(session, int32(num))
code = pb.ErrorCode_Success
this.Debug("使用bingo命令", log.Fields{"uid": session.GetUserId(), "0": datas[1]})
this.Debug("使用bingo命令",
log.Field{Key: "uid", Value: session.GetUserId()},
log.Field{Key: "0", Value: datas[1]},
)
} else if len(datas) == 2 && (datas[0] == "sociatyexp") { // 设置工会经验
module1, err := this.service.GetModule(comm.ModuleSociaty)
if err != nil {
@ -235,7 +273,10 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC
}
module1.(comm.ISociaty).BingoSetExp(session, int32(num))
code = pb.ErrorCode_Success
this.Debug("使用bingo命令", log.Fields{"uid": session.GetUserId(), "0": datas[1]})
this.Debug("使用bingo命令",
log.Field{Key: "uid", Value: session.GetUserId()},
log.Field{Key: "0", Value: datas[1]},
)
} else if len(datas) == 2 && (datas[0] == "sociatyactivity") { // 设置工会活跃度
module1, err := this.service.GetModule(comm.ModuleSociaty)
if err != nil {
@ -248,7 +289,10 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC
}
module1.(comm.ISociaty).BingoSetActivity(session, int32(num))
code = pb.ErrorCode_Success
this.Debug("使用bingo命令", log.Fields{"uid": session.GetUserId(), "0": datas[1]})
this.Debug("使用bingo命令",
log.Field{Key: "uid", Value: session.GetUserId()},
log.Field{Key: "0", Value: datas[1]},
)
} else if len(datas) == 1 && (datas[0] == "alltask") { // 完成所有世界任务
module, err := this.service.GetModule(comm.ModuleWorldtask)
if err != nil {
@ -256,7 +300,9 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC
}
if wt, ok := module.(comm.IWorldtask); ok {
if err = wt.BingoAllTask(session); err != nil {
this.Error("bingo 世界任务", log.Fields{"params": datas, "err": err.Error()})
this.Error("bingo 世界任务",
log.Field{Key: "param", Value: datas},
log.Field{Key: "err", Value: err.Error()})
}
}
@ -267,7 +313,10 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC
}
if wt, ok := module.(comm.IGrowtask); ok {
if err = wt.BingoAllGrowTask(session); err != nil {
this.Error("bingo 成长任务", log.Fields{"params": datas, "err": err.Error()})
this.Error("bingo 成长任务",
log.Field{Key: "param", Value: datas},
log.Field{Key: "err", Value: err.Error()},
)
}
}
@ -288,8 +337,11 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC
if code != pb.ErrorCode_Success {
this.Errorf("资源发放失败,%v", code)
}
this.Debug("使用bingo命令", log.Fields{"uid": session.GetUserId(), "param": datas[0], "res": res})
this.Debug("使用bingo命令",
log.Field{Key: "uid", Value: session.GetUserId()},
log.Field{Key: "param", Value: datas[0]},
log.Field{Key: "res", Value: res},
)
}
}
@ -299,7 +351,7 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC
}
func (this *GM) Rpc_ModuleGMCreateCmd(ctx context.Context, args *pb.RPCGeneralReqA2, reply *pb.EmptyResp) (err error) {
this.Debug("Rpc_ModuleGMCreateCmd", log.Fields{"args": args.String()})
this.Debug("Rpc_ModuleGMCreateCmd", log.Field{Key: "args", Value: args.String()})
if args.Param1 == "" || args.Param2 == "" {
err = errors.New("请求参数错误")
}

View File

@ -45,7 +45,7 @@ func (m *Growtask) BingoAllGrowTask(session comm.IUserSession) error {
//初始任务
init, err := m.modelGrowtask.initGrowtask(uid, 1)
if err != nil {
m.Error("初始任务", log.Fields{"uid": uid})
m.Error("初始任务", log.Field{Key: "uid", Value: uid})
return err
}
gt.InitTaskList = init.InitTaskList
@ -53,7 +53,7 @@ func (m *Growtask) BingoAllGrowTask(session comm.IUserSession) error {
//中级任务
mid, err := m.modelGrowtask.initGrowtask(uid, 2)
if err != nil {
m.Error("中级任务", log.Fields{"uid": uid})
m.Error("中级任务", log.Field{Key: "uid", Value: uid})
return err
}
gt.MidTaskList = mid.MidTaskList
@ -61,7 +61,7 @@ func (m *Growtask) BingoAllGrowTask(session comm.IUserSession) error {
//高级任务
high, err := m.modelGrowtask.initGrowtask(uid, 3)
if err != nil {
m.Error("高级任务", log.Fields{"uid": uid})
m.Error("高级任务", log.Field{Key: "uid", Value: uid})
return err
}
gt.HighTaskList = high.HighTaskList

View File

@ -237,7 +237,7 @@ func (this *Library) getLibraryByObjID(uid, oid string) *pb.DBLibrary {
}
func (this *Library) Rpc_ModuleFetter(ctx context.Context, args *pb.RPCGeneralReqA2, reply *pb.EmptyResp) (err error) {
this.Debug("Rpc_ModuleFetter", log.Fields{"args": args.String()})
this.Debug("Rpc_ModuleFetter", log.Field{Key: "args", Value: args.String()})
if args.Param1 == "" || args.Param2 == "" {
err = errors.New("请求参数错误")
}

View File

@ -11,7 +11,7 @@ import (
// 支线剧情-我的主线任务
func (this *apiComp) MaintaskCheck(session comm.IUserSession, req *pb.LinestoryMaintaskReq) (code pb.ErrorCode) {
if req.ChapterId == 0 {
this.moduleLinestory.Error("参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.moduleLinestory.Error("参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
code = pb.ErrorCode_ReqParameterError
}
return

View File

@ -13,7 +13,7 @@ import (
// 章节奖励领取
func (this *apiComp) ReceiveCheck(session comm.IUserSession, req *pb.LinestoryReceiveReq) (code pb.ErrorCode) {
if req.ChapterId == 0 {
this.moduleLinestory.Error("参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.moduleLinestory.Error("参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
code = pb.ErrorCode_ReqParameterError
}
return
@ -26,7 +26,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.LinestoryReceive
uid := session.GetUserId()
conf := this.moduleLinestory.configure.getChapterCfgById(req.ChapterId)
if conf == nil {
this.moduleLinestory.Error("配置未找到", log.Fields{"uid": uid, "chapterId": req.ChapterId})
this.moduleLinestory.Error("配置未找到", log.Field{Key: "uid", Value: uid}, log.Field{Key: "chapterId", Value: req.ChapterId})
code = pb.ErrorCode_ConfigNoFound
return
}
@ -38,13 +38,15 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.LinestoryReceive
} else {
code = pb.ErrorCode_DBError
}
this.moduleLinestory.Error("章节奖励领取失败", log.Fields{"uid": uid, "chapterId": req.ChapterId, "code": code})
this.moduleLinestory.Error("章节奖励领取失败", log.Field{Key: "uid", Value: uid}, log.Field{Key: "chapterId", Value: req.ChapterId}, log.Field{Key: "code", Value: code})
return
}
//发奖
if code = this.moduleLinestory.DispenseRes(session, conf.Reward, true); code != pb.ErrorCode_Success {
this.moduleLinestory.Error("奖励发放失败", log.Fields{"uid": uid, "chapterId": req.ChapterId, "reward": conf.Reward})
this.moduleLinestory.Error("奖励发放失败",
log.Field{Key: "uid", Value: uid}, log.Field{Key: "chapterId", Value: req.ChapterId}, log.Field{Key: "reward", Value: conf.Reward},
)
return
}

View File

@ -78,7 +78,11 @@ func (this *ModelLinestory) getMaintasks(uid string, groupId int32) (list []*pb.
if iwt, ok := module.(comm.IWorldtask); ok {
// 获取玩家世界任务
wt := iwt.GetMyWorldtask(uid)
this.moduleLinestory.Debug("获取玩家世界任务", log.Fields{"uid": uid, "groupId": groupId, "worldtask": wt})
this.moduleLinestory.Debug("获取玩家世界任务",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "groupId", Value: groupId},
log.Field{Key: "worldtask", Value: wt},
)
if wt != nil {
mainTasks := this.moduleLinestory.configure.getMainTaskCfgByGroup(groupId)
for _, conf := range mainTasks {

View File

@ -76,15 +76,15 @@ func (this *ModuleLinestory) isOverRealline(finishTasks []int32) bool {
// 世界任务完成通知
func (this *ModuleLinestory) TaskFinishNotify(uid string, taskId, groupId int32) error {
ls := this.modelLinestory.getLinestory(uid)
log.Debug("支线剧情任务", log.Fields{"uid": uid, "groupId": groupId, "taskId": taskId})
log.Debug("支线剧情任务", log.Field{Key: "uid", Value: uid}, log.Field{Key: "groupId", Value: groupId}, log.Field{Key: "taskId", Value: taskId})
// 校验groupId 或taskId是否合法
if _, ok := this.confTimeline.GetDataMap()[groupId]; !ok {
this.Debug("非支线剧情任务", log.Fields{"uid": uid, "groupId": groupId, "taskId": taskId})
this.Debug("非支线剧情任务", log.Field{Key: "uid", Value: uid}, log.Field{Key: "groupId", Value: groupId}, log.Field{Key: "taskId", Value: taskId})
return comm.NewCustomError(pb.ErrorCode_ReqParameterError)
}
if _, ok := this.confMaintask.GetDataMap()[taskId]; !ok {
this.Debug("非支线剧情任务", log.Fields{"uid": uid, "groupId": groupId, "taskId": taskId})
this.Debug("非支线剧情任务", log.Field{Key: "uid", Value: uid}, log.Field{Key: "groupId", Value: groupId}, log.Field{Key: "taskId", Value: taskId})
return comm.NewCustomError(pb.ErrorCode_ReqParameterError)
}

View File

@ -125,7 +125,7 @@ func (this *Mail) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (red
}
func (this *Mail) Rpc_Mail(ctx context.Context, args *pb.DBMailData) (err error) {
this.Debug("Rpc_Mail", log.Fields{"args": args.String()})
this.Debug("Rpc_Mail", log.Field{Key: "args", Value: args.String()})
var (
session comm.IUserSession
online bool
@ -136,7 +136,7 @@ func (this *Mail) Rpc_Mail(ctx context.Context, args *pb.DBMailData) (err error)
dbModel := db.NewDBModel(comm.TableMail, time.Hour, conn)
_, err = dbModel.DB.InsertOne(comm.TableMail, args)
if err != nil {
this.Error("Create Rpc_Mail failed", log.Fields{"uid": args.Uid, "err": err})
this.Error("Create Rpc_Mail failed", log.Field{Key: "uid", Value: args.Uid}, log.Field{Key: "err", Value: err.Error()})
}
}
}

View File

@ -284,14 +284,14 @@ func (this *ModuleBase) ConsumeRes(session comm.IUserSession, res []*cfg.Gameatn
for k, v := range attrs {
if this.ModuleUser.QueryAttributeValue(session.GetUserId(), k) < -int64(v) { // -v 负负得正
code = pb.ErrorCode_ResNoEnough
this.Warnf("资源不足", log.Fields{"uid": session.GetUserId(), "T": k, "N": v})
this.Warnf("资源不足", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "T", Value: k}, log.Field{Key: "N", Value: v})
return
}
}
for k, v := range items {
if int32(this.ModuleItems.QueryItemAmount(session.GetUserId(), k)) < -v {
code = pb.ErrorCode_ResNoEnough
this.Warnf("道具不足", log.Fields{"uid": session.GetUserId(), "T": k, "N": v})
this.Warnf("道具不足", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "T", Value: k}, log.Field{Key: "N", Value: v})
return
}
}
@ -301,7 +301,7 @@ func (this *ModuleBase) ConsumeRes(session comm.IUserSession, res []*cfg.Gameatn
if code != pb.ErrorCode_Success {
return
}
this.Debug("消耗玩家资源", log.Fields{"uid": session.GetUserId(), "attrs": attrs})
this.Debug("消耗玩家资源", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "attrs", Value: attrs})
if count, ok := attrs[comm.ResDiamond]; ok {
this.ModuleRtask.SendToRtask(session, comm.Rtype104, -count)
}
@ -311,7 +311,7 @@ func (this *ModuleBase) ConsumeRes(session comm.IUserSession, res []*cfg.Gameatn
if code != pb.ErrorCode_Success {
return
}
this.Debug("消耗道具资源", log.Fields{"uid": session.GetUserId(), "items": items})
this.Debug("消耗玩家资源", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "items", Value: items})
}
return
@ -416,26 +416,26 @@ func (this *ModuleBase) GetDBModuleByUid(uid, tableName string, expired time.Dur
}
//日志接口
func (this *ModuleBase) Debug(msg string, args log.Fields) {
this.options.GetLog().Debug(msg, args)
func (this *ModuleBase) Debug(msg string, args ...log.Field) {
this.options.GetLog().Debug(msg, args...)
}
func (this *ModuleBase) Info(msg string, args log.Fields) {
this.options.GetLog().Info(msg, args)
func (this *ModuleBase) Info(msg string, args ...log.Field) {
this.options.GetLog().Info(msg, args...)
}
func (this *ModuleBase) Print(msg string, args log.Fields) {
this.options.GetLog().Print(msg, args)
func (this *ModuleBase) Print(msg string, args ...log.Field) {
this.options.GetLog().Print(msg, args...)
}
func (this *ModuleBase) Warn(msg string, args log.Fields) {
this.options.GetLog().Warn(msg, args)
func (this *ModuleBase) Warn(msg string, args ...log.Field) {
this.options.GetLog().Warn(msg, args...)
}
func (this *ModuleBase) Error(msg string, args log.Fields) {
this.options.GetLog().Error(msg, args)
func (this *ModuleBase) Error(msg string, args ...log.Field) {
this.options.GetLog().Error(msg, args...)
}
func (this *ModuleBase) Panic(msg string, args log.Fields) {
this.options.GetLog().Panic(msg, args)
func (this *ModuleBase) Panic(msg string, args ...log.Field) {
this.options.GetLog().Panic(msg, args...)
}
func (this *ModuleBase) Fatal(msg string, args log.Fields) {
this.options.GetLog().Fatal(msg, args)
func (this *ModuleBase) Fatal(msg string, args ...log.Field) {
this.options.GetLog().Fatal(msg, args...)
}
func (this *ModuleBase) Debugf(format string, args ...interface{}) {
@ -482,24 +482,24 @@ func (this *ModuleBase) Panicln(args ...interface{}) {
this.options.GetLog().Panicln(args...)
}
func (this *ModuleBase) DebugWithField(msg string, fields log.Fields) {
func (this *ModuleBase) DebugWithField(msg string, fields ...log.Field) {
}
func (this *ModuleBase) InfoWithField(msg string, fields log.Fields) {
func (this *ModuleBase) InfoWithField(msg string, fields ...log.Field) {
}
func (this *ModuleBase) PrintWithField(msg string, fields log.Fields) {
func (this *ModuleBase) PrintWithField(msg string, fields ...log.Field) {
}
func (this *ModuleBase) WarnWithField(msg string, fields log.Fields) {
func (this *ModuleBase) WarnWithField(msg string, fields ...log.Field) {
}
func (this *ModuleBase) ErrorWithField(msg string, fields log.Fields) {
func (this *ModuleBase) ErrorWithField(msg string, fields ...log.Field) {
}
func (this *ModuleBase) FatalWithField(msg string, fields log.Fields) {
func (this *ModuleBase) FatalWithField(msg string, fields ...log.Field) {
}
func (this *ModuleBase) PanicWithField(msg string, fields log.Fields) {
func (this *ModuleBase) PanicWithField(msg string, fields ...log.Field) {
}

View File

@ -85,10 +85,10 @@ func (this *Moonfantasy) Trigger(session comm.IUserSession, source *pb.BattleRep
err error
)
if source == nil || source.Info == nil {
this.Error("Trigger", log.Fields{"err": "source is nil"})
this.Error("Trigger", log.Field{Key: "err", Value: "source is nil"})
return
}
this.Debug("Trigger", log.Fields{"session": session.ToString(), "ptype": source.Info.Ptype})
this.Debug("Trigger", log.Field{Key: "session", Value: session.ToString()}, log.Field{Key: "ptype", Value: source.Info.Ptype})
if triggerData, err = this.configure.GettriggerData(int32(source.Info.Ptype)); err == nil && triggerData.Open {
n, _ := rand.Int(rand.Reader, big.NewInt(1000))
if int32(n.Int64()) < triggerData.DreamlandPro {
@ -111,7 +111,7 @@ func (this *Moonfantasy) Trigger(session comm.IUserSession, source *pb.BattleRep
//接收区服worker发起的秘境事件
func (this *Moonfantasy) Rpc_ModuleMoonfantasyTrigger(ctx context.Context, args *pb.RPCGeneralReqA1, reply *pb.EmptyResp) (err error) {
this.Debug("Rpc_ModuleMoonfantasyTrigger", log.Fields{"args": args.String()})
this.Debug("Rpc_ModuleMoonfantasyTrigger", log.Field{Key: "args", Value: args.String()})
if args.Param1 == "" {
err = errors.New("参数异常!")
return

View File

@ -203,7 +203,7 @@ func (this *Pagoda) CheckPoint6(uid string) bool {
}
func (this *Pagoda) Rpc_ModuleSeasonPagodaReward(ctx context.Context, args *pb.EmptyReq, reply *pb.EmptyResp) {
this.Debug("Rpc_ModuleSeasonPagodaReward", log.Fields{"args": args.String()})
this.Debug("Rpc_ModuleSeasonPagodaReward", log.Field{Key: "args", Value: args.String()})
this.modulerank.seasonSettlement()
}

View File

@ -62,7 +62,7 @@ func (this *Pay) OnInstallComp() {
//RPC-----------------------------------------------------------------------------------------------------------------------
func (this *Pay) Rpc_ModulePayDelivery(ctx context.Context, args *pb.PayDeliveryReq, reply *pb.PayDeliveryResp) (err error) {
this.Debug("Rpc_ModulePayDelivery", log.Fields{"args": args.String()})
this.Debug("Rpc_ModulePayDelivery", log.Field{Key: "args", Value: args.String()})
var (
conf *cfg.GameRechargeData
info *pb.DBUserPay

View File

@ -23,7 +23,7 @@ var _ comm.IRtask = (*ModuleRtask)(nil)
// 限定条件
type rtaskCondi struct {
condId int32 //任务条件配置ID
condId int32 //任务条件配置ID
verify verifyHandle //校验任务条件
find condiFindHandle //检索任务条件
update updateDataHandle //更新任务数据
@ -230,7 +230,11 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T
return
}
this.Debug("任务事件触发", log.Fields{"uid": uid, "taskType": rtaskType, "params": params})
this.Debug("任务事件触发",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "taskType", Value: rtaskType},
log.Field{Key: "params", Value: params},
)
var (
err error
condiId int32
@ -240,13 +244,19 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T
for _, codiConf := range this.configure.getRtaskCondis(int32(rtaskType)) {
v, ok := this.handleMap[codiConf.Id]
if !ok {
this.Warn("未注册事件处理器", log.Fields{"uid": uid, "condiId": codiConf.Id})
this.Warn("未注册事件处理器",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "condiId", Value: codiConf.Id},
)
code = pb.ErrorCode_RtaskCondiNoFound
return
}
if v.find == nil {
this.Warn("未设置find Handle", log.Fields{"uid": uid, "condiId": codiConf.Id})
this.Warn("未设置find Handle",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "condiId", Value: codiConf.Id},
)
return
}
@ -263,9 +273,9 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T
// update
for _, v := range condis {
conf, err:= this.configure.getRtaskTypeById(v.condId)
if err!= nil {
this.Errorln(err)
conf, err := this.configure.getRtaskTypeById(v.condId)
if err != nil {
this.Errorln(err)
code = pb.ErrorCode_RtaskCondiNoFound
return
}
@ -297,7 +307,11 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T
notifyErr.Code = pb.ErrorCode_UserSessionNobeing
session.SendMsg(string(comm.ModuleWorldtask), "finish", notifyErr)
} else {
log.Error("任务条件达成通知", log.Fields{"uid": uid, "condId": conf.Id, "err": err.Error()})
log.Error("任务条件达成通知",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "condId", Value: conf.Id},
log.Field{Key: "err", Value: err.Error()},
)
}
}
}
@ -365,7 +379,9 @@ func (this *ModuleRtask) ChangeCondi(uid string, data map[int32]*pb.RtaskData) e
//接收区服worker发起的秘境事件
func (this *ModuleRtask) Rpc_ModuleRtaskSendTask(ctx context.Context, args *pb.RPCRTaskReq, reply *pb.EmptyResp) (err error) {
this.Debug("Rpc_ModuleRtaskSendTask", log.Fields{"args": args.String()})
this.Debug("Rpc_ModuleRtaskSendTask",
log.Field{Key: "args", Value: args.String()},
)
if args.Uid == "" {
err = errors.New("参数异常!")
return

View File

@ -63,7 +63,12 @@ func (this *ModelRtaskRecord) overrideUpdate(uid string, cfg *cfg.GameRdtaskCond
return
}
}
log.Debug("覆盖数值更新", log.Fields{"uid": uid, "condiId": cfg.Id, "params": vals, "updated": record.Vals[cfg.Id]})
log.Debug("覆盖数值更新",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "condiId", Value: cfg.Id},
log.Field{Key: "params", Value: vals},
log.Field{Key: "updated", Value: record.Vals[cfg.Id]},
)
this.listenTask(uid, cfg.Id)
return
}
@ -110,7 +115,12 @@ func (this *ModelRtaskRecord) addUpdate(uid string, cfg *cfg.GameRdtaskCondiData
}
err = this.Change(uid, update)
}
log.Debug("累计次数更新", log.Fields{"uid": uid, "condiId": cfg.Id, "params": vals, "updated": record.Vals[cfg.Id]})
log.Debug("累计次数更新",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "condiId", Value: cfg.Id},
log.Field{Key: "params", Value: vals},
log.Field{Key: "updated", Value: record.Vals[cfg.Id]},
)
this.listenTask(uid, cfg.Id)
return

View File

@ -140,7 +140,7 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq)
var _items []*cfg.GameShopitemData
for _, v := range shopconf.Shopitem {
if _items, err = this.module.configure.GetShopItemsConfigureByGroups(v, udata); err != nil || len(_items) == 0 {
this.module.Error("no founf shopgroup", log.Fields{"gid": v})
this.module.Error("no founf shopgroup", log.Field{Key: "gid", Value: v})
code = pb.ErrorCode_SystemError
return
}

View File

@ -23,7 +23,7 @@ func (this *apiComp) Accuse(session comm.IUserSession, req *pb.SociatyAccuseReq)
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty != nil && sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid})
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
@ -41,10 +41,13 @@ func (this *apiComp) Accuse(session comm.IUserSession, req *pb.SociatyAccuseReq)
var customErr = new(comm.CustomError)
if errors.As(err, &customErr) {
code = customErr.Code
}else{
} else {
code = pb.ErrorCode_DBError
}
this.module.Error("弹劾", log.Fields{"uid": uid, "sociatyId": sociaty.Id})
this.module.Error("弹劾",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
)
return
}

View File

@ -19,7 +19,7 @@ func (this *apiComp) Activitylist(session comm.IUserSession, req *pb.SociatyActi
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty != nil && sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid})
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}

View File

@ -11,7 +11,7 @@ import (
// 活跃度领取
func (this *apiComp) ActivityreceiveCheck(session comm.IUserSession, req *pb.SociatyActivityReceiveReq) (code pb.ErrorCode) {
if req.Id == 0 {
this.module.Error("活跃度领取参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.module.Error("活跃度领取参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
code = pb.ErrorCode_ReqParameterError
}
return
@ -25,7 +25,7 @@ func (this *apiComp) Activityreceive(session comm.IUserSession, req *pb.SociatyA
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid})
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
@ -50,14 +50,19 @@ func (this *apiComp) Activityreceive(session comm.IUserSession, req *pb.SociatyA
//是否满足领取条件
if sociaty.Activity < conf.Activity {
code = pb.ErrorCode_SociatyActivityNoEnough
this.module.Debug("活跃度不足", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "confId": req.Id,
"实际活跃度": sociaty.Activity, "期望活跃度": conf.Activity})
this.module.Debug("活跃度不足",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
log.Field{Key: "confId", Value: req.Id},
log.Field{Key: "实际活跃度", Value: sociaty.Activity},
log.Field{Key: "期望活跃度", Value: conf.Activity},
)
return
}
// 活跃度领取
if err := this.module.modelSociatyTask.activityReceive(req.Id, sociaty.Id, uid); err != nil {
this.module.Error("活跃度领取", log.Fields{"uid": uid, "params": req})
this.module.Error("活跃度领取", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
code = pb.ErrorCode_DBError
return
}

View File

@ -14,7 +14,7 @@ import (
func (this *apiComp) AgreeCheck(session comm.IUserSession, req *pb.SociatyAgreeReq) (code pb.ErrorCode) {
if req.Uid == "" {
code = pb.ErrorCode_ReqParameterError
this.module.Error("公会申请-同意参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.module.Error("公会申请-同意参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
}
return
}
@ -27,7 +27,7 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.SociatyAgreeReq) (
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty != nil && sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid})
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
@ -47,7 +47,11 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.SociatyAgreeReq) (
} else {
code = pb.ErrorCode_DBError
}
this.module.Error("公会审核-同意", log.Fields{"uid": uid, "申请人": req.Uid, "sociatyId": sociaty.Id})
this.module.Error("公会审核-同意",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "申请人", Value: req.Uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
)
return
}
@ -55,7 +59,11 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.SociatyAgreeReq) (
this.module.ModuleRtask.SendToRtask(session, comm.Rtype109, 1)
// 发邮件
if err := this.module.modelSociaty.sendMail("GuildApproved", []string{sociaty.Name}, []string{req.Uid}); err != nil {
this.module.Error("发送邮件 模板ID:GuildApproved", log.Fields{"uid": uid, "申请人": req.Uid, "sociatyId": sociaty.Id})
this.module.Error("发送邮件 模板ID:GuildApproved",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "申请人", Value: req.Uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
)
}
rsp := &pb.SociatyAgreeResp{
@ -73,7 +81,11 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.SociatyAgreeReq) (
Uid: uid,
SociatyId: sociaty.Id,
}, req.Uid); err != nil {
this.module.Error("审核通过推送", log.Fields{"uid": uid, "申请人": req.Uid, "sociatyId": sociaty.Id})
this.module.Error("审核通过推送",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "申请人", Value: req.Uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
)
}
return
}

View File

@ -15,7 +15,7 @@ import (
func (this *apiComp) ApplyCheck(session comm.IUserSession, req *pb.SociatyApplyReq) (code pb.ErrorCode) {
if req.SociatyId == "" {
code = pb.ErrorCode_ReqParameterError
this.module.Error("公会申请参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.module.Error("公会申请参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
}
return
}
@ -30,14 +30,14 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) (
sociaty := this.module.modelSociaty.getSociaty(req.SociatyId)
if sociaty != nil && sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("公会未找到", log.Fields{"uid": uid, "sociatyId": req.SociatyId})
this.module.Error("公会未找到", log.Field{Key: "uid", Value: uid}, log.Field{Key: "sociatyId", Value: req.SociatyId})
return
}
// userex
userEx, err := this.module.ModuleUser.GetUserExpand(uid)
if err != nil {
this.module.Error("GetRemoteUserExpand", log.Fields{"uid": uid, "err": err.Error()})
this.module.Error("GetRemoteUserExpand", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err.Error()})
code = pb.ErrorCode_UserSessionNobeing
return
}
@ -86,7 +86,11 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) (
} else {
code = pb.ErrorCode_DBError
}
this.module.Error("公会申请", log.Fields{"uid": uid, "sociatyId": req.SociatyId, "err": err.Error()})
this.module.Error("公会申请",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: req.SociatyId},
log.Field{Key: "err", Value: err.Error()},
)
return
}

View File

@ -13,7 +13,7 @@ import (
func (this *apiComp) ApplyCancelCheck(session comm.IUserSession, req *pb.SociatyApplyCancelReq) (code pb.ErrorCode) {
if req.SociatyId == "" {
code = pb.ErrorCode_ReqParameterError
this.module.Error("公会申请取消参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.module.Error("公会申请取消参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
}
return
}
@ -27,13 +27,17 @@ func (this *apiComp) ApplyCancel(session comm.IUserSession, req *pb.SociatyApply
sociaty := this.module.modelSociaty.getSociaty(req.SociatyId)
if sociaty != nil && sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("公会未找到", log.Fields{"uid": uid, "sociatyId": req.SociatyId})
this.module.Error("公会未找到", log.Field{Key: "uid", Value: uid}, log.Field{Key: "sociatyId", Value: req.SociatyId})
return
}
if err := this.module.modelSociaty.applyCancel(uid, sociaty); err != nil {
code = pb.ErrorCode_DBError
this.module.Error("申请撤销", log.Fields{"uid": uid, "sociatyId": req.SociatyId, "err": err.Error()})
this.module.Error("申请撤销",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: req.SociatyId},
log.Field{Key: "err", Value: err.Error()},
)
return
}

View File

@ -13,7 +13,7 @@ import (
func (this *apiComp) ApplyListCheck(session comm.IUserSession, req *pb.SociatyApplyListReq) (code pb.ErrorCode) {
if req.SociatyId == "" {
code = pb.ErrorCode_ReqParameterError
this.module.Error("申请列表参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.module.Error("申请列表参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
}
return
}
@ -26,7 +26,10 @@ func (this *apiComp) ApplyList(session comm.IUserSession, req *pb.SociatyApplyLi
sociaty := this.module.modelSociaty.getSociaty(req.SociatyId)
if sociaty != nil && sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("公会未找到", log.Fields{"uid": uid, "sociatyId": req.SociatyId})
this.module.Error("公会未找到",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: req.SociatyId},
)
return
}

View File

@ -13,7 +13,7 @@ import (
func (this *apiComp) AssignCheck(session comm.IUserSession, req *pb.SociatyAssignReq) (code pb.ErrorCode) {
if req.TargetId == "" {
code = pb.ErrorCode_ReqParameterError
this.module.Error("公会转让参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.module.Error("公会转让参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
}
return
}
@ -26,14 +26,14 @@ func (this *apiComp) Assign(session comm.IUserSession, req *pb.SociatyAssignReq)
uid := session.GetUserId()
if uid == req.TargetId {
code = pb.ErrorCode_ReqParameterError
this.module.Error("不能转让给自己", log.Fields{"uid": uid})
this.module.Error("不能转让给自己", log.Field{Key: "uid", Value: uid})
return
}
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty != nil && sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid})
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
@ -52,7 +52,12 @@ func (this *apiComp) Assign(session comm.IUserSession, req *pb.SociatyAssignReq)
// 公会转让
if err := this.module.modelSociaty.assign(uid, req.TargetId, sociaty); err != nil {
code = pb.ErrorCode_DBError
this.module.Errorf("公会转让", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "targetId": req.TargetId, "err": err.Error()})
this.module.Error("公会转让",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
log.Field{Key: "targetId", Value: req.TargetId},
log.Field{Key: "uid", Value: err.Error()},
)
return
}
@ -65,8 +70,13 @@ func (this *apiComp) Assign(session comm.IUserSession, req *pb.SociatyAssignReq)
} else {
code = pb.ErrorCode_DBError
}
this.module.Error("公会转让日志", log.Fields{"uid": uid, "sociatyId": sociaty.Id,
"targetId": req.TargetId, "日志模板": Log_Job, "err": err.Error()})
this.module.Error("公会转让日志",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
log.Field{Key: "targetId", Value: req.TargetId},
log.Field{Key: "日志模板", Value: Log_Job},
log.Field{Key: "err", Value: err.Error()},
)
}
rsp := &pb.SociatyAssignResp{

View File

@ -17,7 +17,7 @@ import (
// 公会创建
func (this *apiComp) CreateCheck(session comm.IUserSession, req *pb.SociatyCreateReq) (code pb.ErrorCode) {
if len(req.Notice) > 150 || strings.TrimSpace(req.Name) == "" {
this.module.Error("公会创建参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.module.Error("公会创建参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
code = pb.ErrorCode_ReqParameterError
}
return
@ -30,8 +30,8 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq)
uid := session.GetUserId()
user := this.module.ModuleUser.GetUser(uid)
if user == nil{
this.module.Error("GetRmoteUser not found", log.Fields{"uid": uid})
if user == nil {
this.module.Error("GetRmoteUser not found", log.Field{Key: "uid", Value: uid})
code = pb.ErrorCode_UserSessionNobeing
return
}
@ -67,7 +67,10 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq)
//检查钻石
if code = this.module.ConsumeRes(session, []*cfg.Gameatn{this.module.globalConf.GuildBuildCos}, true); code != pb.ErrorCode_Success {
this.module.Warn("资源不足", log.Fields{"uid": uid, "res": this.module.globalConf.GuildBuildCos})
this.module.Warn("资源不足",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "res", Value: this.module.globalConf.GuildBuildCos},
)
return
}
@ -96,7 +99,11 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq)
code = pb.ErrorCode_DBError
}
}
this.module.Error("创建公会", log.Fields{"uid": uid, "params": req, "err": err.Error()})
this.module.Error("创建公会",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "params", Value: req.String()},
log.Field{Key: "err", Value: err.Error()},
)
return
}
@ -107,13 +114,20 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq)
if err = this.module.ModuleUser.ChangeUserExpand(user.Uid, update); err != nil {
code = pb.ErrorCode_DBError
this.module.Error("更新玩家公会ID", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "err": err.Error()})
this.module.Error("更新玩家公会ID",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
log.Field{Key: "err", Value: err.Error()},
)
return
}
// 初始化玩家公会任务
if err := this.module.modelSociatyTask.initSociatyTask(user.Uid, sociaty.Id); err != nil {
this.module.Error("初始化玩家公会任务", log.Fields{"uid": uid, "err": err.Error()})
this.module.Error("初始化玩家公会任务",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "err", Value: err.Error()},
)
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeCreate, &pb.SociatyCreateResp{

View File

@ -14,7 +14,7 @@ import (
func (this *apiComp) DischargeCheck(session comm.IUserSession, req *pb.SociatyDischargeReq) (code pb.ErrorCode) {
if req.TargetId == "" {
code = pb.ErrorCode_ReqParameterError
this.module.Error("踢出公会参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.module.Error("踢出公会参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
}
return
}
@ -27,7 +27,7 @@ func (this *apiComp) Discharge(session comm.IUserSession, req *pb.SociatyDischar
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty != nil && sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid})
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
@ -47,14 +47,23 @@ func (this *apiComp) Discharge(session comm.IUserSession, req *pb.SociatyDischar
} else {
code = pb.ErrorCode_DBError
}
this.module.Error("踢出公会", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "被踢人": req.TargetId, "err": err.Error()})
this.module.Error("踢出公会",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
log.Field{Key: "被踢人", Value: req.TargetId},
log.Field{Key: "err", Value: err.Error()},
)
return
}
// 发邮件
receiver := this.module.modelSociaty.getMemberIds(sociaty)
if err := this.module.modelSociaty.sendMail("GuildExpel", []string{sociaty.Name}, receiver); err != nil {
this.module.Error("发送邮件 模板ID:GuildExpel", log.Fields{"uid": uid, "被踢人": req.TargetId, "sociatyId": sociaty.Id})
this.module.Error("发送邮件 模板ID:GuildExpel",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "被踢人", Value: req.TargetId},
log.Field{Key: "sociatyId", Value: sociaty.Id},
)
}
//清除玩家sociatyId
@ -64,14 +73,23 @@ func (this *apiComp) Discharge(session comm.IUserSession, req *pb.SociatyDischar
if err := this.module.ModuleUser.ChangeUserExpand(req.TargetId, update); err != nil {
code = pb.ErrorCode_DBError
this.module.Error("更新玩家公会ID", log.Fields{"uid": uid, "被踢人": req.TargetId, "err": err.Error()})
this.module.Error("更新玩家公会ID",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "被踢人", Value: req.TargetId},
log.Field{Key: "err", Value: err.Error()},
)
return
}
// 添加日志
if err := this.module.modelSociatyLog.addLog(Log_Discharge, sociaty.Id, uid, req.TargetId); err != nil {
this.module.Error("踢出公会日志", log.Fields{"uid": uid, "sociatyId": sociaty.Id,
"targetId": req.TargetId, "日志模板": Log_Discharge, "err": err.Error()})
this.module.Error("踢出公会日志",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
log.Field{Key: "targetId", Value: req.TargetId},
log.Field{Key: "日志模板", Value: Log_Discharge},
log.Field{Key: "err", Value: err.Error()},
)
}
rsp := &pb.SociatyDischargeResp{

View File

@ -14,7 +14,7 @@ import (
func (this *apiComp) DismissCheck(session comm.IUserSession, req *pb.SociatyDismissReq) (code pb.ErrorCode) {
if req.Dismiss > 1 {
code = pb.ErrorCode_ReqParameterError
this.module.Error("公会解散参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.module.Error("公会解散参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
}
return
}
@ -27,7 +27,7 @@ func (this *apiComp) Dismiss(session comm.IUserSession, req *pb.SociatyDismissRe
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty != nil && sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid})
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}

View File

@ -12,7 +12,7 @@ import (
func (this *apiComp) ListCheck(session comm.IUserSession, req *pb.SociatyListReq) (code pb.ErrorCode) {
if req.Filter > 3 {
code = pb.ErrorCode_ReqParameterError
this.module.Error("公会列表参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.module.Error("公会列表参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
}
return
}

View File

@ -19,7 +19,7 @@ func (this *apiComp) Log(session comm.IUserSession, req *pb.SociatyLogReq) (code
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty != nil && sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid})
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}

View File

@ -19,7 +19,7 @@ func (this *apiComp) Members(session comm.IUserSession, req *pb.SociatyMembersRe
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty != nil && sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid})
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}

View File

@ -19,7 +19,10 @@ func (this *apiComp) Mine(session comm.IUserSession, req *pb.SociatyMineReq) (co
uid := session.GetUserId()
userEx, err := this.module.ModuleUser.GetUserExpand(uid)
if err != nil {
this.module.Error("GetRemoteUserExpand", log.Fields{"uid": uid, "err": err})
this.module.Error("GetRemoteUserExpand",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "err", Value: err.Error()},
)
code = pb.ErrorCode_UserSessionNobeing
return
}
@ -36,7 +39,7 @@ func (this *apiComp) Mine(session comm.IUserSession, req *pb.SociatyMineReq) (co
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty != nil && sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid})
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
@ -55,7 +58,11 @@ func (this *apiComp) Mine(session comm.IUserSession, req *pb.SociatyMineReq) (co
if err := this.module.modelSociatyTask.deleTask(sociaty.Id, uid); err == nil {
// 初始新的公会任务
if err = this.module.modelSociatyTask.initSociatyTask(uid, sociaty.Id); err != nil {
this.module.Error("初始化玩家公会任务", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "err": err})
this.module.Error("初始化玩家公会任务",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
log.Field{Key: "err", Value: err.Error()},
)
}
}
}
@ -70,7 +77,12 @@ func (this *apiComp) Mine(session comm.IUserSession, req *pb.SociatyMineReq) (co
master = this.module.modelSociaty.getMasterInfo(sociaty)
} else {
code = pb.ErrorCode_DBError
this.module.Error("会长弹劾", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "master": master.Uid, "err": err})
this.module.Error("会长弹劾",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
log.Field{Key: "master", Value: master.Uid},
log.Field{Key: "err", Value: err.Error()},
)
}
}
rsp.Sociaty = sociaty

View File

@ -20,7 +20,7 @@ func (this *apiComp) Quit(session comm.IUserSession, req *pb.SociatyQuitReq) (co
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty != nil && sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid})
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
@ -46,14 +46,22 @@ func (this *apiComp) Quit(session comm.IUserSession, req *pb.SociatyQuitReq) (co
if err := this.module.ModuleUser.ChangeUserExpand(uid, update); err != nil {
code = pb.ErrorCode_DBError
this.module.Error("退出公会,更新玩家公会ID", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "err": err.Error()})
this.module.Error("退出公会,更新玩家公会ID",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
log.Field{Key: "err", Value: err.Error()},
)
return
}
// 添加退出公会日志
if err := this.module.modelSociatyLog.addLog(Log_Quit, sociaty.Id, uid); err != nil {
this.module.Error("踢出公会日志", log.Fields{"uid": uid, "sociatyId": sociaty.Id,
"日志模板": Log_Quit, "err": err.Error()})
this.module.Error("踢出公会日志",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
log.Field{Key: "日志模板", Value: Log_Quit},
log.Field{Key: "err", Value: err.Error()},
)
}
rsp := &pb.SociatyQuitResp{

View File

@ -13,7 +13,7 @@ import (
func (this *apiComp) ReceiveCheck(session comm.IUserSession, req *pb.SociatyReceiveReq) (code pb.ErrorCode) {
if req.TaskId == 0 {
code = pb.ErrorCode_ReqParameterError
this.module.Error("公会任务奖励领取参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.module.Error("公会任务奖励领取参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
}
return
}
@ -26,7 +26,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.SociatyReceiveRe
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty != nil && sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid})
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
@ -45,14 +45,24 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.SociatyReceiveRe
// 验证任务是否完成
if err, ok := this.module.modelSociaty.validTask(uid, req.TaskId); err != nil || !ok {
code = pb.ErrorCode_SociatyTaskValidation
this.module.Error("公会任务未通过", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "taskId": req.TaskId, "err": err.Error()})
this.module.Error("公会任务未通过",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
log.Field{Key: "taskId", Value: req.TaskId},
log.Field{Key: "err", Value: err.Error()},
)
return
}
// 奖励领取
if err := this.module.modelSociatyTask.receive(req.TaskId, sociaty.Id, uid); err != nil {
code = pb.ErrorCode_SociatyRewardReceive
this.module.Error("领取公会任务奖励", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "taskId": req.TaskId, "err": err.Error()})
this.module.Error("领取公会任务奖励",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
log.Field{Key: "taskId", Value: req.TaskId},
log.Field{Key: "err", Value: err.Error()},
)
return
}
@ -61,19 +71,34 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.SociatyReceiveRe
if ok {
// 发放个人奖励
if code = this.module.DispenseRes(session, conf.Reward, true); code != pb.ErrorCode_Success {
this.module.Error("发放公会个人奖励失败", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "taskId": req.TaskId, "code": code})
this.module.Error("发放公会个人奖励失败",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
log.Field{Key: "taskId", Value: req.TaskId},
log.Field{Key: "code", Value: code},
)
}
}
// 更新公会经验和活跃度
if err := this.module.modelSociaty.updateResourceFromTask(sociaty, conf); err != nil {
this.module.Error("更新公会资源", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "taskId": req.TaskId, "err": err.Error()})
this.module.Error("更新公会资源",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
log.Field{Key: "taskId", Value: req.TaskId},
log.Field{Key: "err", Value: err.Error()},
)
return
}
// 更新成员贡献值
if err := this.module.modelSociaty.updateMemberContribution(uid, conf.Contribution, sociaty); err != nil {
this.module.Error("更新公会成员贡献值", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "taskId": req.TaskId, "err": err.Error()})
this.module.Error("更新公会成员贡献值",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
log.Field{Key: "taskId", Value: req.TaskId},
log.Field{Key: "err", Value: err.Error()},
)
return
}

View File

@ -13,7 +13,7 @@ import (
func (this *apiComp) RefuseCheck(session comm.IUserSession, req *pb.SociatyRefuseReq) (code pb.ErrorCode) {
if req.Uid == "" {
code = pb.ErrorCode_ReqParameterError
this.module.Error("公会申请审核-拒绝参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.module.Error("公会申请审核-拒绝参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
}
return
}
@ -26,7 +26,7 @@ func (this *apiComp) Refuse(session comm.IUserSession, req *pb.SociatyRefuseReq)
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty != nil && sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid})
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
@ -48,7 +48,11 @@ func (this *apiComp) Refuse(session comm.IUserSession, req *pb.SociatyRefuseReq)
// 拒绝公会申请
if err := this.module.modelSociaty.refuse(req.Uid, sociaty); err != nil {
code = pb.ErrorCode_SociatyRefuse
this.module.Error("申请拒绝", log.Fields{"uid": uid, "拒绝目标人": req.Uid, "err": err.Error()})
this.module.Error("申请拒绝",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "拒绝目标人", Value: req.Uid},
log.Field{Key: "err", Value: err.Error()},
)
return
}

View File

@ -12,7 +12,7 @@ import (
func (this *apiComp) SearchCheck(session comm.IUserSession, req *pb.SociatySearchReq) (code pb.ErrorCode) {
if req.Name == "" {
code = pb.ErrorCode_ReqParameterError
this.module.Error("公会搜索参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.module.Error("公会搜索参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
}
return
}

View File

@ -13,7 +13,7 @@ import (
func (this *apiComp) SettingCheck(session comm.IUserSession, req *pb.SociatySettingReq) (code pb.ErrorCode) {
if req.ApplyLv == 0 || req.Icon == "" {
code = pb.ErrorCode_ReqParameterError
this.module.Error("公会设置参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.module.Error("公会设置参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
}
return
}
@ -27,7 +27,7 @@ func (this *apiComp) Setting(session comm.IUserSession, req *pb.SociatySettingRe
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty != nil && sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid})
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
@ -46,7 +46,12 @@ func (this *apiComp) Setting(session comm.IUserSession, req *pb.SociatySettingRe
// 设置
if err := this.module.modelSociaty.setting(sociaty); err != nil {
code = pb.ErrorCode_SociatySetting
this.module.Error("公会修改", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "params": req, "err": err.Error()})
this.module.Error("公会修改",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
log.Field{Key: "params", Value: req},
log.Field{Key: "err", Value: err.Error()},
)
return
}

View File

@ -12,7 +12,7 @@ import (
func (this *apiComp) SettingJobCheck(session comm.IUserSession, req *pb.SociatySettingJobReq) (code pb.ErrorCode) {
if req.TargetId == "" || req.Job == 0 {
code = pb.ErrorCode_ReqParameterError
this.module.Error("公会设置职位参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.module.Error("公会设置职位参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
}
return
}
@ -26,7 +26,7 @@ func (this *apiComp) SettingJob(session comm.IUserSession, req *pb.SociatySettin
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty != nil && sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid})
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}

View File

@ -22,7 +22,7 @@ func (this *apiComp) Sign(session comm.IUserSession, req *pb.SociatySignReq) (co
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty != nil && sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid})
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
@ -41,7 +41,7 @@ func (this *apiComp) Sign(session comm.IUserSession, req *pb.SociatySignReq) (co
// 签到
if err := this.module.modelSociaty.sign(uid, sociaty); err != nil {
code = pb.ErrorCode_SociatyAgree
this.module.Error("签到失败", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "err": err.Error()})
this.module.Error("签到失败", log.Field{Key: "uid", Value: uid}, log.Field{Key: "sociatyId", Value: sociaty.Id}, log.Field{Key: "err", Value: err.Error()})
return
}
@ -54,7 +54,11 @@ func (this *apiComp) Sign(session comm.IUserSession, req *pb.SociatySignReq) (co
if code = this.module.DispenseRes(session, v.Reward, true); code == pb.ErrorCode_Success {
signCfgId = v.Id
} else {
log.Error("发放签到奖励失败", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "code": code})
log.Error("发放签到奖励失败",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
log.Field{Key: "code", Value: code},
)
}
break
}
@ -64,11 +68,20 @@ func (this *apiComp) Sign(session comm.IUserSession, req *pb.SociatySignReq) (co
// 更新公会经验
if cfg.Exp.T == "guildexp" {
if err := this.module.modelSociaty.updateSociatyExp(cfg.Exp.N, sociaty); err != nil {
this.module.Error("公会经验更新", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "经验": cfg.Exp.N, "err": err.Error()})
this.module.Error("公会经验更新",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
log.Field{Key: "经验", Value: cfg.Exp.N},
log.Field{Key: "err", Value: err.Error()},
)
}
// 更新等级
if err := this.module.modelSociaty.changeLv(sociaty); err != nil {
this.module.Error("公会等级更新", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "err": err.Error()})
this.module.Error("公会等级更新",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
log.Field{Key: "err", Value: err.Error()},
)
}
}
}

View File

@ -19,7 +19,7 @@ func (this *apiComp) TaskList(session comm.IUserSession, req *pb.SociatyTaskList
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid})
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
rsp := &pb.SociatyTaskListResp{}

View File

@ -33,9 +33,9 @@ const (
type ModelSociaty struct {
modules.MCompModel
moduleSociaty *Sociaty
service core.IService
EventApp *event_v2.App
module *Sociaty
service core.IService
EventApp *event_v2.App
}
type SociatyListen struct {
@ -49,7 +49,7 @@ func (this *ModelSociaty) Init(service core.IService, module core.IModule, comp
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
Keys: bsonx.Doc{{Key: "_id", Value: bsonx.Int32(1)}},
})
this.moduleSociaty = module.(*Sociaty)
this.module = module.(*Sociaty)
this.service = service
this.EventApp = event_v2.NewApp()
this.EventApp.Listen(comm.EventSociatyRankChanged, this.rankDataChanged)
@ -90,7 +90,7 @@ func (this *ModelSociaty) isNameExist(name string) error {
// 公会列表
func (this *ModelSociaty) list(uid string, filter pb.SociatyListFilter) (list []*pb.DBSociaty) {
user := this.moduleSociaty.ModuleUser.GetUser(uid)
user := this.module.ModuleUser.GetUser(uid)
// if err != nil {
// return
// }
@ -98,17 +98,17 @@ func (this *ModelSociaty) list(uid string, filter pb.SociatyListFilter) (list []
return
}
logFields := log.Fields{"uid": uid, "filter": filter}
logFields := []log.Field{{Key: "uid", Value: uid}, {Key: "filter", Value: filter}}
switch filter {
case pb.SociatyListFilter_ALL: //所有
if err := this.GetList("", &list); err != nil {
log.Error("公会列表", logFields)
log.Error("公会列表", logFields...)
return
}
case pb.SociatyListFilter_CONDI: //满足条件
//玩家等级大于等于公会的申请等级限制
if err := this.GetList("", &list); err != nil {
log.Error("公会列表", logFields)
log.Error("公会列表", logFields...)
return
}
var newList []*pb.DBSociaty
@ -131,7 +131,7 @@ func (this *ModelSociaty) list(uid string, filter pb.SociatyListFilter) (list []
}
case pb.SociatyListFilter_APPLYING: //申请中
if err := this.GetList("", &list); err != nil {
log.Error("公会列表", logFields)
log.Error("公会列表", logFields...)
return
}
@ -168,7 +168,7 @@ func (this *ModelSociaty) findByName(name string) *pb.DBSociaty {
func (this *ModelSociaty) getSociaty(sociatyId string) (sociaty *pb.DBSociaty) {
sociaty = &pb.DBSociaty{}
if err := this.GetListObj(comm.RDS_EMPTY, sociatyId, sociaty); err != nil {
log.Error("GetListObj", log.Fields{"sociatyId": sociatyId})
log.Error("GetListObj", log.Field{Key: "sociatyId", Value: sociatyId})
return
}
return
@ -195,8 +195,8 @@ func (this *ModelSociaty) getUserSociaty(uid string) (sociaty *pb.DBSociaty) {
userEx *pb.DBUserExpand
err error
)
if this.moduleSociaty.IsCross() {
userEx, err = this.moduleSociaty.ModuleUser.GetUserExpand(uid)
if this.module.IsCross() {
userEx, err = this.module.ModuleUser.GetUserExpand(uid)
if err != nil {
return
}
@ -210,22 +210,22 @@ func (this *ModelSociaty) getUserSociaty(uid string) (sociaty *pb.DBSociaty) {
}
}
} else {
userEx, err = this.moduleSociaty.ModuleUser.GetUserExpand(uid)
userEx, err = this.module.ModuleUser.GetUserExpand(uid)
if err != nil {
return
}
if userEx.SociatyId != "" {
sociaty = &pb.DBSociaty{}
if err = this.moduleSociaty.service.AcrossClusterRpcCall(
if err = this.module.service.AcrossClusterRpcCall(
context.Background(),
this.moduleSociaty.GetCrossTag(),
this.module.GetCrossTag(),
comm.Service_Worker,
string(comm.Rpc_ModuleSociaty),
pb.RPCGeneralReqA1{Param1: userEx.SociatyId},
sociaty); err != nil {
this.moduleSociaty.Errorln(err)
this.module.Errorln(err)
}
log.Debug("跨服获取公会信息", log.Fields{"uid": uid, "sociatyId": sociaty.Id})
this.module.Debug("跨服获取公会信息", log.Field{Key: "uid", Value: uid}, log.Field{Key: "sociatyId", Value: sociaty.Id})
}
}
@ -250,7 +250,7 @@ func (this *ModelSociaty) apply(uid string, sociaty *pb.DBSociaty) (isCheck bool
return isCheck, err
}
//初始玩家公会任务
this.moduleSociaty.modelSociatyTask.initSociatyTask(uid, sociaty.Id)
this.module.modelSociatyTask.initSociatyTask(uid, sociaty.Id)
}
return
}
@ -284,7 +284,7 @@ func (this *ModelSociaty) isApplied(uid string, sociaty *pb.DBSociaty) bool {
// 申请列表
func (this *ModelSociaty) applyList(sociaty *pb.DBSociaty) (list []*pb.SociatyMemberInfo) {
for _, r := range sociaty.ApplyRecord {
user := this.moduleSociaty.ModuleUser.GetUser(r.Uid)
user := this.module.ModuleUser.GetUser(r.Uid)
if user == nil {
continue
}
@ -330,21 +330,21 @@ func (this *ModelSociaty) isRight(uid string, sociaty *pb.DBSociaty, jobs ...pb.
// 更新公会经验
func (this *ModelSociaty) updateSociaty(sociatyId string, update map[string]interface{}) error {
if this.moduleSociaty.IsCross() {
if this.module.IsCross() {
return this.ChangeList(comm.RDS_EMPTY, sociatyId, update)
} else {
req := &SociatyUpdateParam{
SociatyId: sociatyId,
Update: update,
}
if err := this.moduleSociaty.service.AcrossClusterRpcCall(
if err := this.module.service.AcrossClusterRpcCall(
context.Background(),
this.moduleSociaty.GetCrossTag(),
this.module.GetCrossTag(),
comm.Service_Worker,
string(comm.Rpc_ModuleSociatyUpdate),
req,
&pb.EmptyResp{}); err != nil {
this.moduleSociaty.Errorln(err)
this.module.Errorln(err)
}
}
return nil
@ -372,8 +372,8 @@ func (this *ModelSociaty) dismiss(sociaty *pb.DBSociaty) error {
return err
}
//推送
this.moduleSociaty.SendMsgToUsers(
string(this.moduleSociaty.GetType()),
this.module.SendMsgToUsers(
string(this.module.GetType()),
"pdismiss",
&pb.SociatyPDismissPush{SociatyId: sociaty.Id},
this.getMemberIds(sociaty)...)
@ -417,12 +417,12 @@ func (this *ModelSociaty) addMember(uid string, sociaty *pb.DBSociaty) error {
updateEx := map[string]interface{}{
"sociatyId": sociaty.Id,
}
if err := this.moduleSociaty.ModuleUser.ChangeUserExpand(uid, updateEx); err != nil {
if err := this.module.ModuleUser.ChangeUserExpand(uid, updateEx); err != nil {
return err
}
// 记录日志
this.moduleSociaty.modelSociatyLog.addLog(Log_Add, sociaty.Id, uid)
this.module.modelSociatyLog.addLog(Log_Add, sociaty.Id, uid)
return nil
}
@ -442,7 +442,7 @@ func (this *ModelSociaty) sendMail(confId string, params []string, receiver []st
// 成员列表
func (this *ModelSociaty) members(sociaty *pb.DBSociaty) (list []*pb.SociatyMemberInfo) {
for _, m := range sociaty.Members {
user := this.moduleSociaty.ModuleUser.GetUser(m.Uid)
user := this.module.ModuleUser.GetUser(m.Uid)
if user == nil {
continue
}
@ -482,7 +482,7 @@ func (this *ModelSociaty) agree(uid string, sociaty *pb.DBSociaty) error {
}
//初始玩家公会任务
return this.moduleSociaty.modelSociatyTask.initSociatyTask(uid, sociaty.Id)
return this.module.modelSociatyTask.initSociatyTask(uid, sociaty.Id)
}
//拒绝
@ -552,7 +552,7 @@ func (this *ModelSociaty) settingJob(targetId string, job pb.SociatyJob, sociaty
func (this *ModelSociaty) getMasterInfo(sociaty *pb.DBSociaty) *pb.SociatyMemberInfo {
for _, m := range sociaty.Members {
if m.Job == pb.SociatyJob_PRESIDENT {
user := this.moduleSociaty.ModuleUser.GetUser(m.Uid)
user := this.module.ModuleUser.GetUser(m.Uid)
if user == nil {
continue
}
@ -575,12 +575,12 @@ func (this *ModelSociaty) accuse(sociaty *pb.DBSociaty) error {
return comm.NewCustomError(pb.ErrorCode_SociatyNoMaster)
}
user := this.moduleSociaty.ModuleUser.GetUser(master.Uid)
user := this.module.ModuleUser.GetUser(master.Uid)
if user == nil {
return comm.NewCustomError(pb.ErrorCode_UserSessionNobeing)
}
globalCnf := this.moduleSociaty.globalConf
globalCnf := this.module.globalConf
//会长离线时间
now := configure.Now().Unix()
@ -823,7 +823,7 @@ func (this *ModelSociaty) rankDataChanged(event interface{}, next func(event int
func (this *ModelSociaty) rank() (rank []*pb.DBSociatyRank) {
var list []*pb.DBSociaty
if err := this.GetList("", &list); err != nil {
log.Error("公会列表", log.Fields{"err": err.Error()})
this.module.Error("公会列表", log.Field{Key: "err", Value: err.Error()})
return nil
}
@ -848,7 +848,7 @@ func (this *ModelSociaty) rank() (rank []*pb.DBSociatyRank) {
// 等级更新
func (this *ModelSociaty) changeLv(sociaty *pb.DBSociaty) error {
ggl, err := this.moduleSociaty.configure.getSociatyLvCfg()
ggl, err := this.module.configure.getSociatyLvCfg()
if err != nil {
return err
}
@ -882,7 +882,7 @@ func (this *ModelSociaty) changeLv(sociaty *pb.DBSociaty) error {
// 获取可容纳的最大上限
func (this *ModelSociaty) getMemberMax(sociaty *pb.DBSociaty) int32 {
ggl, err := this.moduleSociaty.configure.getSociatyLvCfg()
ggl, err := this.module.configure.getSociatyLvCfg()
if err != nil {
return 0
}
@ -900,14 +900,14 @@ func (this *ModelSociaty) getMemberMax(sociaty *pb.DBSociaty) int32 {
// 校验任务完成状态
func (this *ModelSociaty) validTask(uid string, taskId int32) (err error, ok bool) {
rsp := &pb.DBRtaskRecord{}
if err = this.moduleSociaty.ModuleRtask.RemoteCheckCondi(uid, taskId, rsp); err != nil {
if err = this.module.ModuleRtask.RemoteCheckCondi(uid, taskId, rsp); err != nil {
return
}
// 遍历玩家任务数据
if data, ok := rsp.Vals[taskId]; ok {
//查找表配置
conf, ok := this.moduleSociaty.rtaskCondConf.GetDataMap()[taskId]
conf, ok := this.module.rtaskCondConf.GetDataMap()[taskId]
if ok {
if data.Rtype == conf.Type && data.Data[0] >= conf.Data1 {
return nil, true
@ -924,7 +924,7 @@ func (this *ModelSociaty) memberClear(sociaty *pb.DBSociaty) error {
for _, m := range sociaty.Members {
receiver = append(receiver, m.Uid)
//清除成员任务
if err := this.moduleSociaty.modelSociatyTask.deleTask(sociaty.Id, m.Uid); err != nil {
if err := this.module.modelSociatyTask.deleTask(sociaty.Id, m.Uid); err != nil {
log.Errorf("删除玩家 uid:%s 公会 sociatyId:%s err:%v", m.Uid, sociaty.Id, err)
}
@ -932,12 +932,12 @@ func (this *ModelSociaty) memberClear(sociaty *pb.DBSociaty) error {
update := map[string]interface{}{
"sociatyId": "", //公会ID置空
}
if err := this.moduleSociaty.ModuleUser.ChangeUserExpand(m.Uid, update); err != nil {
if err := this.module.ModuleUser.ChangeUserExpand(m.Uid, update); err != nil {
log.Errorf("更新玩家公会ID err:%v", err)
}
//清除公会日志
if err := this.moduleSociaty.modelSociatyLog.logDelete(sociaty.Id); err != nil {
if err := this.module.modelSociatyLog.logDelete(sociaty.Id); err != nil {
log.Errorf("删除公会日志 sociatyId:%s err:%v", sociaty.Id, err)
}
}

View File

@ -162,7 +162,7 @@ func (this *ModelSociatyLog) addLog(tag Tag, sociatyId string, params ...string)
func (this *ModelSociatyLog) logList(sociatyId string) (slist []*pb.SociatyLog) {
sociatyLog := &pb.DBSociatyLog{}
if err := this.Get(sociatyId, sociatyLog); err != nil {
log.Error("公会日志列表", log.Fields{"sociatyId": sociatyId})
log.Error("公会日志列表", log.Field{Key: "sociatyId", Value: sociatyId})
return nil
}

View File

@ -124,7 +124,7 @@ func (this *Sociaty) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (
reddot = make(map[comm.ReddotType]bool)
sociaty := this.modelSociaty.getUserSociaty(session.GetUserId())
if sociaty == nil || sociaty.Id == "" {
log.Warn("公会红点未获得公会信息", log.Fields{"uid": session.GetUserId()})
log.Warn("公会红点未获得公会信息", log.Field{Key: "uid", Value: session.GetUserId()})
for _, v := range rid {
reddot[v] = false
}
@ -155,7 +155,7 @@ func (this *Sociaty) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (
// 跨服获取公会
func (this *Sociaty) RpcGetSociaty(ctx context.Context, req *pb.RPCGeneralReqA1, reply *pb.DBSociaty) error {
this.Debug("Rpc_ModuleSociaty", log.Fields{"req": req})
this.Debug("Rpc_ModuleSociaty", log.Field{Key: "req", Value: req.String()})
sociaty := this.modelSociaty.getSociaty(req.Param1)
reply.Id = sociaty.Id
reply.Lv = sociaty.Lv
@ -190,7 +190,7 @@ func (this *Sociaty) RpcUpdateSociaty(ctx context.Context, req *SociatyUpdatePar
func (this *Sociaty) BingoSetExp(session comm.IUserSession, exp int32) error {
sociaty := this.modelSociaty.getUserSociaty(session.GetUserId())
if sociaty == nil || sociaty.Id == "" {
log.Warn("未获得公会信息", log.Fields{"uid": session.GetUserId()})
log.Warn("未获得公会信息", log.Field{Key: "uid", Value: session.GetUserId()})
return comm.NewCustomError(pb.ErrorCode_SociatyNoFound)
}
sociaty.Exp += exp
@ -210,7 +210,7 @@ func (this *Sociaty) BingoSetExp(session comm.IUserSession, exp int32) error {
func (this *Sociaty) BingoSetActivity(session comm.IUserSession, activity int32) error {
sociaty := this.modelSociaty.getUserSociaty(session.GetUserId())
if sociaty == nil || sociaty.Id == "" {
log.Warn("未获得公会信息", log.Fields{"uid": session.GetUserId()})
log.Warn("未获得公会信息", log.Field{Key: "uid", Value: session.GetUserId()})
return comm.NewCustomError(pb.ErrorCode_SociatyNoFound)
}

View File

@ -84,7 +84,11 @@ func (this *apiComp) ActiveReceive(session comm.IUserSession, req *pb.TaskActive
if len(rewards) > 0 {
//派发奖励
if code = this.moduleTask.DispenseRes(session, rewards, true); code != pb.ErrorCode_Success {
this.moduleTask.Error("活跃度奖励", log.Fields{"uid": uid, "rewards": rewards, "code": code})
this.moduleTask.Error("活跃度奖励",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "rewards", Value: rewards},
log.Field{Key: "code", Value: code},
)
}
}

View File

@ -99,7 +99,11 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.TaskReceiveReq)
//奖励
if code = this.moduleTask.DispenseRes(session, conf.Reword, true); code != pb.ErrorCode_Success {
this.moduleTask.Error("发送奖励", log.Fields{"uid": uid, "reward": conf.Reword, "code": code})
this.moduleTask.Error("发送奖励",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "rewards", Value: conf.Reword},
log.Field{Key: "code", Value: code},
)
return
}

View File

@ -354,7 +354,10 @@ func (this *ModelTask) modifyUserTask(uid string, taskId int32, data map[string]
//清空任务
func (this *ModelTask) clearTask(uid string, taskTag ...comm.TaskTag) {
if len(taskTag) == 0 {
this.moduleTask.Error("TaskTag参数缺失", log.Fields{"uid": uid, "params": taskTag})
this.moduleTask.Error("TaskTag参数缺失",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "params", Value: taskTag},
)
return
}
var task *pb.DBTask
@ -364,7 +367,10 @@ func (this *ModelTask) clearTask(uid string, taskTag ...comm.TaskTag) {
}
if task == nil {
this.moduleTask.Error("任务数据空", log.Fields{"uid": uid, "taskTag": taskTag})
this.moduleTask.Error("任务数据空",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "taskTag", Value: taskTag},
)
return
}
@ -379,7 +385,7 @@ func (this *ModelTask) clearTask(uid string, taskTag ...comm.TaskTag) {
}
}
if err := this.moduleTask.ModuleRtask.ChangeCondi(uid, dr.Vals); err != nil {
this.moduleTask.Error("更新任务条件数据", log.Fields{"uid": uid})
this.moduleTask.Error("更新任务条件数据", log.Field{Key: "uid", Value: uid})
}
update["dayList"] = make([]*pb.TaskData, 0)
} else if taskTag[0] == comm.TASK_WEEKLY {
@ -390,7 +396,7 @@ func (this *ModelTask) clearTask(uid string, taskTag ...comm.TaskTag) {
}
}
if err := this.moduleTask.ModuleRtask.ChangeCondi(uid, dr.Vals); err != nil {
this.moduleTask.Error("更新任务条件数据", log.Fields{"uid": uid})
this.moduleTask.Error("更新任务条件数据", log.Field{Key: "uid", Value: uid})
}
update["weekList"] = make([]*pb.TaskData, 0)
} else if taskTag[0] == comm.TASK_ACHIEVE {
@ -401,13 +407,13 @@ func (this *ModelTask) clearTask(uid string, taskTag ...comm.TaskTag) {
}
}
if err := this.moduleTask.ModuleRtask.ChangeCondi(uid, dr.Vals); err != nil {
this.moduleTask.Error("更新任务条件数据", log.Fields{"uid": uid})
this.moduleTask.Error("更新任务条件数据", log.Field{Key: "uid", Value: uid})
}
update["weekList"] = make([]*pb.TaskData, 0)
}
if err := this.moduleTask.modelTask.Change(uid, update); err != nil {
this.moduleTask.Error("清空任务数据", log.Fields{"uid": uid})
this.moduleTask.Error("清空任务数据", log.Field{Key: "uid", Value: uid})
}
}
@ -438,7 +444,7 @@ func (this *ModelTask) doTaskHandle(event interface{}, next func(event interface
task, ok := this.checkTask(tl.Uid, conf.Key)
if !ok {
this.moduleTask.Debug("任务已完成", log.Fields{"uid": tl.Uid, "任务ID": conf.Key})
this.moduleTask.Debug("任务已完成", log.Field{Key: "uid", Value: tl.Uid}, log.Field{Key: "任务ID", Value: conf.Key})
continue
}
@ -446,7 +452,7 @@ func (this *ModelTask) doTaskHandle(event interface{}, next func(event interface
progress int32
update map[string]interface{}
)
if code := this.moduleTask.ModuleRtask.CheckCondi(tl.Uid, conf.TypeId); code == pb.ErrorCode_Success {
// update data
if ret != nil && len(ret.Data) > 0 {
@ -468,7 +474,9 @@ func (this *ModelTask) doTaskHandle(event interface{}, next func(event interface
return
}
this.moduleTask.Debug("更新任务",
log.Fields{"uid": tl.Uid, "任务ID": conf.Key, "事件ID": conf.TypeId, "progress": update["progress"], "status": update["status"]},
log.Field{Key: "uid", Value: tl.Uid}, log.Field{Key: "任务ID", Value: conf.Key},
log.Field{Key: "事件ID", Value: conf.TypeId}, log.Field{Key: "progress", Value: update["progress"]},
log.Field{Key: "status", Value: update["status"]},
)
}
return

View File

@ -67,7 +67,7 @@ func (this *ChatComp) Start() (err error) {
}
cronStr := fmt.Sprintf("0 %d %d ? * %s", v1.TimeM, v1.TimeH, weekStr)
this.module.Debug("注册Chat广播公告消息", log.Fields{"cronStr": cronStr, "text": v1.Text})
this.module.Debug("注册Chat广播公告消息", log.Field{Key: "cronStr", Value: cronStr}, log.Field{Key: "text", Value: v1.Text})
if id, err = cron.AddFunc(cronStr, this.chatNoticen(v1)); err != nil {
this.module.Errorf("cron.AddFunc:%s err:%v", cronStr, err)
continue
@ -91,7 +91,7 @@ func (this *ChatComp) chatNoticen(sys *cfg.GameChatSystemData) func() {
AppendInt: int64(sys.Key),
}
data, _ := anypb.New(&pb.ChatMessagePush{Chat: msg})
this.module.Debug("广播公告消息", log.Fields{"chat": sys.Text})
this.module.Debug("广播公告消息", log.Field{Key: "chat", Value: sys.Text})
if err := this.module.service.RpcBroadcast(context.Background(), comm.Service_Gateway, string(comm.Rpc_GatewaySendRadioMsg), pb.UserMessage{
MainType: string(comm.ModuleChat),
SubType: "message",

View File

@ -71,26 +71,26 @@ func (this *Timer) SetName(name string) {
}
//日志接口
func (this *Timer) Debug(msg string, args log.Fields) {
this.options.GetLog().Debug(msg, args)
func (this *Timer) Debug(msg string, args ...log.Field) {
this.options.GetLog().Debug(msg, args...)
}
func (this *Timer) Info(msg string, args log.Fields) {
this.options.GetLog().Info(msg, args)
func (this *Timer) Info(msg string, args ...log.Field) {
this.options.GetLog().Info(msg, args...)
}
func (this *Timer) Print(msg string, args log.Fields) {
this.options.GetLog().Print(msg, args)
func (this *Timer) Print(msg string, args ...log.Field) {
this.options.GetLog().Print(msg, args...)
}
func (this *Timer) Warn(msg string, args log.Fields) {
this.options.GetLog().Warn(msg, args)
func (this *Timer) Warn(msg string, args ...log.Field) {
this.options.GetLog().Warn(msg, args...)
}
func (this *Timer) Error(msg string, args log.Fields) {
this.options.GetLog().Error(msg, args)
func (this *Timer) Error(msg string, args ...log.Field) {
this.options.GetLog().Error(msg, args...)
}
func (this *Timer) Panic(msg string, args log.Fields) {
this.options.GetLog().Panic(msg, args)
func (this *Timer) Panic(msg string, args ...log.Field) {
this.options.GetLog().Panic(msg, args...)
}
func (this *Timer) Fatal(msg string, args log.Fields) {
this.options.GetLog().Fatal(msg, args)
func (this *Timer) Fatal(msg string, args ...log.Field) {
this.options.GetLog().Fatal(msg, args...)
}
func (this *Timer) Debugf(format string, args ...interface{}) {

View File

@ -14,7 +14,10 @@ func (this *apiComp) CreateCheck(session comm.IUserSession, req *pb.UserCreateRe
name := strings.TrimSpace(req.NickName)
if name == "" || len(name) > 30 {
code = pb.ErrorCode_UserNickNameEmpty
this.module.Error("参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.module.Error("参数错误",
log.Field{Key: "uid", Value: session.GetUserId()},
log.Field{Key: "params", Value: req.String()},
)
}
return
@ -62,7 +65,11 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (c
if err := this.module.modelUser.Change(uid, update); err != nil {
code = pb.ErrorCode_DBError
this.module.Error("创角", log.Fields{"uid": uid, "params": update, "err": err.Error()})
this.module.Error("创角",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "params", Value: update},
log.Field{Key: "err", Value: err.Error()},
)
return
}
@ -72,7 +79,11 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (c
}
if err := this.module.modelExpand.ChangeUserExpand(session.GetUserId(), initUpdate); err != nil {
code = pb.ErrorCode_DBError
this.module.Error("创建初始修改名称次数", log.Fields{"uid": uid, "param": initUpdate, "err": err.Error()})
this.module.Error("创建初始修改名称次数",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "params", Value: initUpdate},
log.Field{Key: "err", Value: err.Error()},
)
return
}
var (

View File

@ -20,7 +20,10 @@ func (this *apiComp) GetTujian(session comm.IUserSession, req *pb.UserGetTujianR
uid := session.GetUserId()
rsp := &pb.UserGetTujianResp{}
if result, err := this.module.modelExpand.GetUserExpand(uid); err != nil {
this.module.Error("玩家扩展数据", log.Fields{"uid": uid, "err": err.Error()})
this.module.Error("玩家扩展数据",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "err", Value: err.Error()},
)
return
} else {
for k, v := range result.Tujian {

View File

@ -47,7 +47,11 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod
user, err = this.module.modelUser.FindByAccount(req.Sid, req.Account)
if err != nil {
if err != mongo.ErrNoDocuments {
log.Error("User_FindByAccount", log.Fields{"sid": req.Sid, "account": req.Account, "err": err.Error()})
log.Error("User_FindByAccount",
log.Field{Key: "uid", Value: req.Sid},
log.Field{Key: "account", Value: req.Account},
log.Field{Key: "err", Value: err.Error()},
)
return
}
}

View File

@ -34,17 +34,17 @@ func (this *ModelExpand) GetUserExpand(uid string) (result *pb.DBUserExpand, err
result = &pb.DBUserExpand{}
if db.IsCross() {
if model, err := this.module.GetDBModuleByUid(uid, this.TableName, this.Expired); err != nil {
this.module.Error("Cross GetDBModuleByUid", log.Fields{"uid": uid})
this.module.Error("Cross GetDBModuleByUid", log.Field{Key: "uid", Value: uid})
return result, err
} else {
if err = model.Get(uid, result); err != nil && mongo.ErrNoDocuments != err {
this.module.Error("Cross Get", log.Fields{"uid": uid})
this.module.Error("Cross Get", log.Field{Key: "uid", Value: uid})
return result, err
}
}
} else {
if err = this.Get(uid, result); err != nil && mongo.ErrNoDocuments != err {
this.module.Error("Get", log.Fields{"uid": uid})
this.module.Error("Get", log.Field{Key: "uid", Value: uid})
}
}
return

View File

@ -78,7 +78,7 @@ func (this *ModelUser) User_Create(user *pb.DBUser) (err error) {
_, err = this.DB.InsertOne(comm.TableUser, user)
key := fmt.Sprintf("%s:%s", this.TableName, user.Uid)
if err = this.Redis.HMSet(key, user); err != nil {
this.module.Error("创建用户", log.Fields{"sid": user.Sid, "account": user.Binduid})
this.module.Error("创建用户", log.Field{Key: "sid", Value: user.Sid}, log.Field{Key: "account", Value: user.Binduid})
return
}
return
@ -209,7 +209,11 @@ func (this *ModelUser) ChangeVipExp(event interface{}, next func(event interface
"vipexp": vipExp,
}
if err := this.module.modelUser.Change(ul.session.GetUserId(), update); err != nil {
this.module.Error("玩家Vip等级经验更新", log.Fields{"uid": ul.session.GetUserId(), "vipLv": vipLv, "vipExp": vipExp})
this.module.Error("玩家Vip等级经验更新",
log.Field{Key: "uid", Value: ul.session.GetUserId()},
log.Field{Key: "vipLv", Value: vipLv},
log.Field{Key: "vipExp", Value: vipExp},
)
return
}
if ul.viplv != vipLv { // 新获得了vip
@ -261,15 +265,26 @@ func (this *ModelUser) ChangeLevel(event interface{}, next func(event interface{
"exp": curExp,
}
if err := this.module.modelUser.Change(ul.session.GetUserId(), update); err != nil {
this.module.Error("玩家等级经验更新", log.Fields{"uid": ul.session.GetUserId(), "exp": curExp, "lv": curLv})
this.module.Error("玩家等级经验更新",
log.Field{Key: "uid", Value: ul.session.GetUserId()},
log.Field{Key: "exp", Value: curExp},
log.Field{Key: "lv", Value: curLv},
)
return
}
if err := ul.session.SendMsg(string(this.module.GetType()), UserSubTypeLvChangedPush,
&pb.UserLvChangedPush{Uid: ul.session.GetUserId(), Exp: curExp, Lv: curLv}); err != nil {
this.module.Error("玩家等级变化 UserSubTypeLvChangedPush推送失败", log.Fields{"uid": ul.session.GetUserId(), "exp": curExp, "lv": curLv})
this.module.Error("玩家等级变化 UserSubTypeLvChangedPush推送失败",
log.Field{Key: "uid", Value: ul.session.GetUserId()},
log.Field{Key: "exp", Value: curExp},
log.Field{Key: "lv", Value: curLv},
)
}
if code := this.module.DispenseRes(ul.session, rewards, true); code != pb.ErrorCode_Success {
this.module.Error("资源发放", log.Fields{"uid": ul.session.GetUserId(), "rewards": rewards})
this.module.Error("资源发放",
log.Field{Key: "uid", Value: ul.session.GetUserId()},
log.Field{Key: "rewards", Value: rewards},
)
}
mc, err := this.module.service.GetModule(comm.ModuleChat)
@ -285,12 +300,20 @@ func (this *ModelUser) ChangeLevel(event interface{}, next func(event interface{
"exp": curExp,
}
if err := this.module.modelUser.Change(ul.session.GetUserId(), update); err != nil {
this.module.Error("玩家经验更新", log.Fields{"uid": ul.session.GetUserId(), "exp": curExp, "lv": curLv})
this.module.Error("玩家经验更新",
log.Field{Key: "uid", Value: ul.session.GetUserId()},
log.Field{Key: "exp", Value: curExp},
log.Field{Key: "lv", Value: curLv},
)
return
}
if err := ul.session.SendMsg(string(this.module.GetType()), "reschanged",
&pb.UserResChangedPush{Exp: curExp}); err != nil {
this.module.Error("玩家经验变化 UserResChangedPush推送失败", log.Fields{"uid": ul.session.GetUserId(), "exp": curExp, "lv": curLv})
this.module.Error("玩家经验变化 UserResChangedPush推送失败",
log.Field{Key: "uid", Value: ul.session.GetUserId()},
log.Field{Key: "exp", Value: curExp},
log.Field{Key: "lv", Value: curLv},
)
}
}
}

View File

@ -235,7 +235,11 @@ func (this *User) QueryAttributeValue(uid string, attr string) (value int64) {
func (this *User) change(session comm.IUserSession, attr string, add int32) (change *pb.UserResChangedPush, code pb.ErrorCode) {
if add == 0 {
log.Warn("attr no changed", log.Fields{"uid": session.GetUserId(), "attr": attr, "add": add})
log.Warn("attr no changed",
log.Field{Key: "uid", Value: session.GetUserId()},
log.Field{Key: "attr", Value: attr},
log.Field{Key: "add", Value: add},
)
// code = pb.ErrorCode_ReqParameterError
return
}

View File

@ -58,26 +58,26 @@ func (this *Web) OnInstallComp() {
//日志
//日志接口
func (this *Web) Debug(msg string, args log.Fields) {
this.options.GetLog().Debug(msg, args)
func (this *Web) Debug(msg string, args ...log.Field) {
this.options.GetLog().Debug(msg, args...)
}
func (this *Web) Info(msg string, args log.Fields) {
this.options.GetLog().Info(msg, args)
func (this *Web) Info(msg string, args ...log.Field) {
this.options.GetLog().Info(msg, args...)
}
func (this *Web) Print(msg string, args log.Fields) {
this.options.GetLog().Print(msg, args)
func (this *Web) Print(msg string, args ...log.Field) {
this.options.GetLog().Print(msg, args...)
}
func (this *Web) Warn(msg string, args log.Fields) {
this.options.GetLog().Warn(msg, args)
func (this *Web) Warn(msg string, args ...log.Field) {
this.options.GetLog().Warn(msg, args...)
}
func (this *Web) Error(msg string, args log.Fields) {
this.options.GetLog().Error(msg, args)
func (this *Web) Error(msg string, args ...log.Field) {
this.options.GetLog().Error(msg, args...)
}
func (this *Web) Panic(msg string, args log.Fields) {
this.options.GetLog().Panic(msg, args)
func (this *Web) Panic(msg string, args ...log.Field) {
this.options.GetLog().Panic(msg, args...)
}
func (this *Web) Fatal(msg string, args log.Fields) {
this.options.GetLog().Fatal(msg, args)
func (this *Web) Fatal(msg string, args ...log.Field) {
this.options.GetLog().Fatal(msg, args...)
}
func (this *Web) Debugf(format string, args ...interface{}) {

View File

@ -12,7 +12,10 @@ import (
// 战斗结束的请求
func (this *apiComp) BattlefinishCheck(session comm.IUserSession, req *pb.WorldtaskBattleFinishReq) (code pb.ErrorCode) {
if req.BattleConfId == 0 || req.TaskId == 0 || req.Report == nil {
this.module.Error("世界任务战斗结束参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.module.Error("世界任务战斗结束参数错误",
log.Field{Key: "uid", Value: session.GetUserId()},
log.Field{Key: "params", Value: req.String()},
)
code = pb.ErrorCode_ReqParameterError
}
return
@ -50,7 +53,10 @@ func (this *apiComp) Battlefinish(session comm.IUserSession, req *pb.WorldtaskBa
if taskConf.Completetask == 0 {
if err := this.module.modelWorldtask.finishTask(taskConf.Group, req.TaskId, userTask); err != nil {
code = pb.ErrorCode_DBError
this.module.Error("世界任务战斗结果", log.Fields{"uid": uid, "err": err.Error()})
this.module.Error("世界任务战斗结果",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "err", Value: err.Error()},
)
return
}
@ -63,7 +69,10 @@ func (this *apiComp) Battlefinish(session comm.IUserSession, req *pb.WorldtaskBa
if err := session.SendMsg(string(this.module.GetType()), "nexttask", &pb.WorldtaskNexttaskPush{
NextTaskId: taskConf.IdAfter,
}); err != nil {
log.Error("任务条件达成推送", log.Fields{"uid": uid, "err": err})
log.Error("任务条件达成推送",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "err", Value: err.Error()},
)
return
}
}
@ -84,12 +93,19 @@ func (this *apiComp) Battlefinish(session comm.IUserSession, req *pb.WorldtaskBa
if isWin {
if battleConf, ok := this.module.worldBattleConf.GetDataMap()[req.BattleConfId]; ok {
if code := this.module.DispenseRes(session, []*cfg.Gameatn{battleConf.Playexp}, true); code != pb.ErrorCode_Success {
this.module.Error("世界任务战斗玩家经验结算", log.Fields{"uid": uid, "playerExp": battleConf.Playexp})
this.module.Error("世界任务战斗玩家经验结算",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "playerExp", Value: battleConf.Playexp},
)
}
}
}
}
this.module.Debug("校验战报", log.Fields{"uid": session.GetUserId(), "taskId": req.TaskId, "战斗结果": isWin})
this.module.Debug("校验战报",
log.Field{Key: "uid", Value: session.GetUserId()},
log.Field{Key: "taskId", Value: req.TaskId},
log.Field{Key: "战斗结果", Value: isWin},
)
}
if err := session.SendMsg(string(this.module.GetType()), WorldtaskBattleFinish, rsp); err != nil {

View File

@ -11,7 +11,10 @@ import (
// 战斗开始
func (this *apiComp) BattlestartCheck(session comm.IUserSession, req *pb.WorldtaskBattleStartReq) (code pb.ErrorCode) {
if req.BattleConfId == 0 || req.Battle == nil {
this.module.Error("世界任务战斗开始参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.module.Error("世界任务战斗开始参数错误",
log.Field{Key: "uid", Value: session.GetUserId()},
log.Field{Key: "params", Value: req.String()},
)
code = pb.ErrorCode_ReqParameterError
}
return
@ -25,7 +28,10 @@ func (this *apiComp) Battlestart(session comm.IUserSession, req *pb.WorldtaskBat
battleConf, err := this.module.configure.getWorldtaskBattleById(req.BattleConfId)
if err != nil || battleConf == nil {
code = pb.ErrorCode_ConfigNoFound
log.Error("战斗配置未找到", log.Fields{"uid": uid, "battleConfId": req.BattleConfId})
log.Error("战斗配置未找到",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "battleConfId", Value: req.BattleConfId},
)
return
}

View File

@ -12,7 +12,7 @@ import (
func (this *apiComp) FinishCheck(session comm.IUserSession, req *pb.WorldtaskFinishReq) (code pb.ErrorCode) {
if req.GroupId == 0 || req.TaskId == 0 {
this.module.Error("世界任务完成参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
this.module.Error("世界任务完成参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
code = pb.ErrorCode_ReqParameterError
}
return
@ -68,7 +68,7 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe
// 前置任务ID 只有世界任务才校验前置
if curTaskConf.Des == 2 {
if !this.module.modelWorldtask.IsPreFinished(userTask, curTaskConf) {
this.module.Debug("前置任务未完成", log.Fields{"uid": uid, "preTaskId": curTaskConf.Ontxe, "taskId": curTaskConf.Key})
this.module.Debug("前置任务未完成", log.Field{Key: "uid", Value: uid}, log.Field{Key: "preTaskId", Value: curTaskConf.Ontxe}, log.Field{Key: "taskId", Value: curTaskConf.Key})
code = pb.ErrorCode_WorldtaskLastUnFinished
return
}
@ -96,25 +96,43 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe
finishCall := func() {
defer func() {
this.module.Debug("世界任务完成", log.Fields{"uid": uid, "params": req, "nextTaskId": nextTaskId})
this.module.Debug("世界任务完成",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "params", Value: req},
log.Field{Key: "nextTaskId", Value: nextTaskId},
)
}()
// 完成任务
if err := this.module.modelWorldtask.finishTask(req.GroupId, req.TaskId, userTask); err != nil {
code = pb.ErrorCode_WorldtaskFinish
this.module.Error("完成任务失败", log.Fields{"uid": uid, "groupId": req.GroupId, "taskId": req.TaskId, "err": err.Error()})
this.module.Error("完成任务失败",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "groupId", Value: req.GroupId},
log.Field{Key: "taskId", Value: req.TaskId},
log.Field{Key: "err", Value: err.Error()},
)
return
}
// 发奖
if code = this.module.DispenseRes(session, curTaskConf.Reword, true); code != pb.ErrorCode_Success {
this.module.Error("资源发放", log.Fields{"uid": uid, "groupId": req.GroupId, "taskId": req.TaskId, "reword": curTaskConf.Reword, "code": code})
this.module.Error("资源发放",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "groupId", Value: req.GroupId},
log.Field{Key: "taskId", Value: req.TaskId},
log.Field{Key: "reword", Value: curTaskConf.Reword},
log.Field{Key: "code", Value: code},
)
}
}
//判断任务是否已完成
for _, t := range userTask.TaskList {
if t.TaskId == req.TaskId {
this.module.Debug("任务已完成,返回下一个", log.Fields{"uid": uid, "taskId": req.TaskId})
this.module.Debug("任务已完成,返回下一个",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "taskId", Value: req.TaskId},
)
finishRsp()
return
}
@ -124,7 +142,10 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe
if c := this.module.ModuleRtask.CheckCondi(uid, curTaskConf.Completetask); c == pb.ErrorCode_Success {
finishCall()
} else {
this.module.Debug("任务完成条件未通过", log.Fields{"uid": uid, "condiId": curTaskConf.Completetask})
this.module.Debug("任务完成条件未通过",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "condiId", Value: curTaskConf.Completetask},
)
if err := session.SendMsg(string(this.module.GetType()), WorldtaskSubtypeFinish, rsp); err != nil {
code = pb.ErrorCode_SystemError
return

View File

@ -17,7 +17,7 @@ func (this *apiComp) Mine(session comm.IUserSession, req *pb.WorldtaskMineReq) (
uid := session.GetUserId()
myWorldtask, err := this.module.modelWorldtask.getWorldtask(uid)
if err != nil {
this.module.Error("获取玩家世界任务失败", log.Fields{"uid": uid, "err": err.Error()})
this.module.Error("获取玩家世界任务失败", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err.Error()})
code = pb.ErrorCode_DBError
return
}

View File

@ -31,7 +31,7 @@ func (this *ModelWorldtask) getWorldtask(uid string) (*pb.DBWorldtask, error) {
d := &pb.DBWorldtask{}
if err := this.Get(uid, d); err != nil {
if err != mongo.ErrNoDocuments {
log.Error("getWorldtask", log.Fields{"uid": uid})
log.Error("getWorldtask", log.Field{Key: "uid", Value: uid})
return d, err
}
}
@ -102,7 +102,12 @@ func (this *ModelWorldtask) finishTask(groupId, taskId int32, task *pb.DBWorldta
if module, err := this.service.GetModule(comm.ModuleLinestory); err == nil {
if iLinestory, ok := module.(comm.ILinestory); ok {
if err := iLinestory.TaskFinishNotify(task.Uid, taskId, groupId); err != nil {
log.Debug("世界任务完成通知支线剧情任务", log.Fields{"uid": task.Uid, "groupId": groupId, "taskId": taskId, "err": err.Error()})
log.Debug("世界任务完成通知支线剧情任务",
log.Field{Key: "uid", Value: task.Uid},
log.Field{Key: "groupId", Value: groupId},
log.Field{Key: "taskId", Value: taskId},
log.Field{Key: "err", Value: err.Error()},
)
}
}
}

View File

@ -66,12 +66,10 @@ func (this *Worldtask) TaskcondNotify(session comm.IUserSession, condId int32) e
}
if len(finishedTaskIds) == 0 {
this.Debug("没有匹配到任务世界任务", log.Fields{"uid": uid, "condId": condId})
this.Debug("没有匹配到任务世界任务", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "condId", Value: condId})
return nil
}
log.Debug("世界任务完成通知-查找到世界任务", log.Fields{"uid": uid, "condId": condId, "params": finishedTaskIds})
this.Debug("世界任务完成通知-查找到世界任务", log.Field{Key: "uid", Value: uid}, log.Field{Key: "condId", Value: condId}, log.Field{Key: "params", Value: finishedTaskIds})
//下一个任务ID
var nextTaskId int32
// 获取用户信息
@ -83,28 +81,28 @@ func (this *Worldtask) TaskcondNotify(session comm.IUserSession, condId int32) e
// 玩家世界任务
userTask, err := this.modelWorldtask.getWorldtask(uid)
if err != nil {
this.Error("获取玩家世界任务", log.Fields{"uid": uid, "condId": condId})
this.Error("获取玩家世界任务", log.Field{Key: "uid", Value: uid}, log.Field{Key: "condId", Value: condId})
return err
}
if userTask.Uid != "" {
//查找任务ID根据condId 可能会找出不同的任务
for groupId, taskId := range finishedTaskIds {
logFields := log.Fields{"uid": uid, "group": groupId, "taskId": taskId, "condId": condId}
logFields := []log.Field{{Key: "uid", Value: uid}, {Key: "group", Value: groupId}, {Key: "taskId", Value: taskId}, {Key: "condId", Value: condId}}
// 判断任务是否已完成
if this.modelWorldtask.isFinished(taskId, userTask.TaskList) {
this.Debug("世界任务已完成", logFields)
this.Debug("世界任务已完成", logFields...)
continue
}
taskConf, err := this.configure.getWorldtaskById(taskId)
if err != nil {
this.Error("world_task config not found", logFields)
this.Error("world_task config not found", logFields...)
return err
}
if taskConf != nil {
if taskConf.Des == 2 { //只有世界任务才校验前置
if !this.modelWorldtask.IsPreFinished(userTask, taskConf) {
this.Debug("世界任务前置任务未完成", logFields)
this.Debug("世界任务前置任务未完成", logFields...)
continue
}
}
@ -112,35 +110,33 @@ func (this *Worldtask) TaskcondNotify(session comm.IUserSession, condId int32) e
// 判断玩家等级要求
if user.Lv < taskConf.Lock {
logFields["当前lv"] = user.Lv
logFields["期望等级"] = taskConf.Lock
this.Debug("等级不满足", logFields)
logFields = append(logFields, log.Field{Key: "当前lv", Value: user.Lv}, log.Field{Key: "期望等级", Value: taskConf.Lock})
this.Debug("等级不满足", logFields...)
return comm.NewCustomError(pb.ErrorCode_WorldtaskLvNotEnough)
}
//完成任务
if err := this.modelWorldtask.finishTask(groupId, taskId, userTask); err != nil {
logFields["err"] = err.Error()
this.Error("世界任务完成", logFields)
logFields = append(logFields, log.Field{Key: "err", Value: err.Error()})
this.Error("世界任务完成", logFields...)
return err
}
this.Debug("任务条件达成完成", logFields)
this.Debug("任务条件达成完成", logFields...)
//发奖
if code := this.DispenseRes(session, taskConf.Reword, true); code != pb.ErrorCode_Success {
logFields["reward"] = taskConf.Reword
logFields["code"] = code
this.Error("资源发放", logFields)
logFields = append(logFields, log.Field{Key: "reward", Value: taskConf.Reword}, log.Field{Key: "code", Value: code})
this.Error("资源发放", logFields...)
}
if nextTaskId != 0 && taskConf.Des == 2 {
if err := session.SendMsg(string(this.GetType()), "nexttask", &pb.WorldtaskNexttaskPush{
NextTaskId: nextTaskId,
}); err != nil {
logFields["err"] = err.Error()
log.Error("任务条件达成推送", logFields)
logFields = append(logFields, log.Field{Key: "err", Value: err.Error()})
log.Error("任务条件达成推送", logFields...)
}
} else {
this.Debug("已经是最后一个任务了", logFields)
this.Debug("已经是最后一个任务了", logFields...)
}
}

View File

@ -105,17 +105,17 @@ func Execute() {
//生成配置
func conf() {
if config, err := readergmconf(gmpath); err != nil {
log.Error("读取区服配置失败!", log.Fields{"err": err})
log.Error("读取区服配置失败!", log.Field{Key: "err", Value: err.Error()})
return
} else {
if ss, err := rederServiceSttings(config); err != nil {
log.Error("转换服务配置异常!", log.Fields{"err": err})
log.Error("转换服务配置异常!", log.Field{Key: "err", Value: err.Error()})
return
} else {
for _, v := range ss {
if sid == "" || fmt.Sprintf("%s_%s", v.Tag, sid) == v.Id {
if err = writeServiceConfig(fmt.Sprintf("./conf/%s.yaml", v.Id), v); err != nil {
log.Error("写入配置文件失败!", log.Fields{"err": err})
log.Error("写入配置文件失败!", log.Field{Key: "err", Value: err.Error()})
return
}
}
@ -128,7 +128,7 @@ func conf() {
//启动程序
func start() {
if config, err := readergmconf(gmpath); err != nil {
log.Error("读取区服配置失败!", log.Fields{"err": err})
log.Error("读取区服配置失败!", log.Field{Key: "err", Value: err.Error()})
} else {
var (
maintes *core.ServiceSttings
@ -136,12 +136,12 @@ func start() {
gateways []*core.ServiceSttings = make([]*core.ServiceSttings, 0)
)
if ss, err := rederServiceSttings(config); err != nil {
log.Error("转换服务配置异常!", log.Fields{"err": err})
log.Error("转换服务配置异常!", log.Field{Key: "err", Value: err.Error()})
} else {
for _, v := range ss {
if sid == "" || fmt.Sprintf("%s_%s", v.Tag, sid) == v.Id {
if err = writeServiceConfig(fmt.Sprintf("./conf/%s.yaml", v.Id), v); err != nil {
log.Error("写入配置文件失败!", log.Fields{"err": err})
log.Error("写入配置文件失败!", log.Field{Key: "err", Value: err.Error()})
return
}
switch v.Type {
@ -165,7 +165,10 @@ func start() {
//优先启动 维护服
if maintes != nil {
if err = startService(maintes); err != nil {
log.Error("启动服务失败!", log.Fields{"id": maintes.Id, "err": err})
log.Error("启动服务失败!",
log.Field{Key: "id", Value: maintes.Id},
log.Field{Key: "err", Value: err.Error()},
)
return
}
}
@ -174,7 +177,10 @@ func start() {
// 业务服
for _, v := range workers {
if err = startService(v); err != nil {
log.Error("启动服务失败!", log.Fields{"id": v.Id, "err": err})
log.Error("启动服务失败!",
log.Field{Key: "id", Value: v.Id},
log.Field{Key: "err", Value: err.Error()},
)
return
}
}
@ -182,7 +188,10 @@ func start() {
// 网关服
for _, v := range gateways {
if err = startService(v); err != nil {
log.Error("启动服务失败!", log.Fields{"id": v.Id, "err": err})
log.Error("启动服务失败!",
log.Field{Key: "id", Value: v.Id},
log.Field{Key: "err", Value: err.Error()},
)
return
}
}
@ -193,11 +202,11 @@ func start() {
//关闭程序
func stop() {
if config, err := readergmconf(gmpath); err != nil {
log.Error("读取区服配置失败!", log.Fields{"err": err})
log.Error("读取区服配置失败!", log.Field{Key: "err", Value: err.Error()})
} else {
if ss, err := rederServiceSttings(config); err != nil {
log.Error("转换服务配置异常!", log.Fields{"err": err})
log.Error("转换服务配置异常!", log.Field{Key: "err", Value: err.Error()})
} else {
for _, v := range ss {
if sid == "" || fmt.Sprintf("%s_%s", v.Tag, sid) == v.Id {
@ -358,7 +367,7 @@ func startService(sseting *core.ServiceSttings) (err error) {
err = fmt.Errorf("服务类型异常 stype:%s", sseting.Type)
return
}
log.Debug("启动外部命令", log.Fields{"cmd": command})
log.Debug("启动外部命令", log.Field{Key: "cmd", Value: command})
cmd = exec.Command("/bin/bash", "-c", command)
if output, err = cmd.CombinedOutput(); err != nil {
return
@ -388,7 +397,7 @@ func stopService(sseting *core.ServiceSttings) (err error) {
err = fmt.Errorf("服务类型异常 stype:%s", sseting.Type)
return
}
log.Debug("启动外部命令", log.Fields{"cmd": command})
log.Debug("启动外部命令", log.Field{Key: "cmd", Value: command})
cmd = exec.Command("/bin/bash", "-c", command)
if output, err = cmd.CombinedOutput(); err != nil {
return

View File

@ -161,13 +161,21 @@ func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessag
}
// log.Errorf("[Handle Api] t:%v m:%s req:%v reply:%v", time.Since(stime), method, msg, reply)
log.Error("[Handle Api]",
log.Fields{"t": time.Since(stime).Milliseconds(), "m": method, "uid": args.UserId, "req": msg, "reply": reply.String()},
log.Field{Key: "t", Value: time.Since(stime).Milliseconds()},
log.Field{Key: "m", Value: method},
log.Field{Key: "uid", Value: args.UserId},
log.Field{Key: "req", Value: msg},
log.Field{Key: "reply", Value: reply.String()},
)
} else {
reply.Reply = session.Polls()
// log.Debugf("[Handle Api] t:%v m:%s uid:%s req:%v reply:%v", time.Since(stime), method, args.UserId, msg, reply)
log.Debug("[Handle Api]",
log.Fields{"t": time.Since(stime).Milliseconds(), "m": method, "uid": args.UserId, "req": msg, "reply": reply.String()},
log.Field{Key: "t", Value: time.Since(stime).Milliseconds()},
log.Field{Key: "m", Value: method},
log.Field{Key: "uid", Value: args.UserId},
log.Field{Key: "req", Value: msg},
log.Field{Key: "reply", Value: reply.String()},
)
}
} else { //未找到消息处理函数

View File

@ -222,7 +222,7 @@ func (this *Configure) checkConfigure() {
log.Errorln(err)
return
}
log.Debug("UpDate Configure", log.Fields{"table": v.Name})
log.Debug("UpDate Configure", log.Field{Key: "table", Value: v.Name})
v.ModTime = fi.ModTime() //重置配置文件修改时间
for _, v := range handle.events {
if v != nil {

View File

@ -71,7 +71,11 @@ func (this *DB) readercrossconf(path string) (err error) {
MongodbUrl: cf.LoaclDB.MongodbUrl,
MongodbDatabase: cf.LoaclDB.MongodbDatabase,
}); err != nil {
log.Error("comment db err!", log.Fields{"stag": cf.AreaId, "db": cf.LoaclDB, "err": err})
log.Error("comment db err!",
log.Field{Key: "stag", Value: cf.AreaId},
log.Field{Key: "db", Value: cf.LoaclDB},
log.Field{Key: "err", Value: err.Error()},
)
return
}
} else {
@ -84,7 +88,11 @@ func (this *DB) readercrossconf(path string) (err error) {
MongodbUrl: v.MongodbUrl,
MongodbDatabase: v.MongodbDatabase,
}); err != nil {
log.Error("comment db err!", log.Fields{"stag": k, "db": v, "err": err})
log.Error("comment db err!",
log.Field{Key: "stag", Value: cf.AreaId},
log.Field{Key: "db", Value: cf.LoaclDB},
log.Field{Key: "err", Value: err.Error()},
)
return
}
}
@ -126,7 +134,11 @@ func (this *DB) SyncServiceList() (err error) {
MongodbUrl: v.MongodbUrl,
MongodbDatabase: v.MongodbDatabase,
}); err != nil {
log.Error("comment db err!", log.Fields{"stag": k, "db": v, "err": err})
log.Error("comment db err!",
log.Field{Key: "stag", Value: cf.AreaId},
log.Field{Key: "db", Value: cf.LoaclDB},
log.Field{Key: "err", Value: err.Error()},
)
return
}
}

View File

@ -28,14 +28,14 @@ func newDBConn(lg log.ILogger, conf DBConfig) (conn *DBConn, err error) {
)
}
if err != nil {
lg.Error(err.Error(), log.Fields{"config": conf})
lg.Error(err.Error(), log.Field{Key: "config", Value: conf})
return
}
if conn.Mgo, err = mgo.NewSys(
mgo.SetMongodbUrl(conf.MongodbUrl),
mgo.SetMongodbDatabase(conf.MongodbDatabase),
); err != nil {
lg.Error(err.Error(), log.Fields{"config": conf})
lg.Error(err.Error(), log.Field{Key: "config", Value: conf})
return
}
go conn.run()

View File

@ -271,7 +271,7 @@ func (this *DBModel) Change(uid string, data map[string]interface{}, opt ...DBOp
func (this *DBModel) ChangeList(uid string, _id string, data map[string]interface{}, opt ...DBOption) (err error) {
//defer log.Debug("DBModel ChangeList", log.Field{Key: "TableName", Value: this.TableName}, log.Field{Key: "uid", Value: uid}, log.Field{Key: "_id", Value: _id}, log.Field{Key: "data", Value: data})
if err = this.Redis.HMSet(this.ukeylist(uid, _id), data); err != nil {
log.Error("DBModel ChangeList", log.Fields{"err": err})
log.Error("DBModel ChangeList", log.Field{Key: "err", Value: err.Error()})
return
}