上传优化代码
This commit is contained in:
parent
4563606628
commit
1a5f02ed31
@ -53,10 +53,20 @@ type Logger struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *Logger) Clone(name string, skip int) ILogger {
|
func (this *Logger) Clone(name string, skip int) ILogger {
|
||||||
|
_name := ""
|
||||||
|
if name == "" {
|
||||||
|
_name = this.name
|
||||||
|
} else {
|
||||||
|
if this.name == "" {
|
||||||
|
_name = name
|
||||||
|
} else {
|
||||||
|
_name = fmt.Sprintf("%s:%s", this.name, name)
|
||||||
|
}
|
||||||
|
}
|
||||||
return &Logger{
|
return &Logger{
|
||||||
config: this.config,
|
config: this.config,
|
||||||
formatter: this.formatter,
|
formatter: this.formatter,
|
||||||
name: fmt.Sprintf("%s:%s", this.name, name),
|
name: _name,
|
||||||
out: this.out,
|
out: this.out,
|
||||||
level: this.level,
|
level: this.level,
|
||||||
addCaller: this.addCaller,
|
addCaller: this.addCaller,
|
||||||
|
@ -74,10 +74,7 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (code
|
|||||||
if msg.Ctype == pb.ChatType_Text { //过滤敏感词
|
if msg.Ctype == pb.ChatType_Text { //过滤敏感词
|
||||||
msg.Content = wordfilter.Replace(msg.Content, '*')
|
msg.Content = wordfilter.Replace(msg.Content, '*')
|
||||||
}
|
}
|
||||||
if err = this.module.modelChat.sendChatToWorld(msg, max_chat); err != nil {
|
go this.module.modelChat.sendChatToWorld(msg, max_chat)
|
||||||
code = pb.ErrorCode_DBError
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype62, 1)
|
this.module.ModuleRtask.SendToRtask(session, comm.Rtype62, 1)
|
||||||
//随机任务
|
//随机任务
|
||||||
// if _, err = this.service.AcrossClusterRpcGo(
|
// if _, err = this.service.AcrossClusterRpcGo(
|
||||||
@ -95,10 +92,7 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (code
|
|||||||
msg.Content = wordfilter.Replace(msg.Content, '*')
|
msg.Content = wordfilter.Replace(msg.Content, '*')
|
||||||
}
|
}
|
||||||
msg.UnionId = req.TargetId
|
msg.UnionId = req.TargetId
|
||||||
if err = this.module.modelChat.sendChatToUnion(msg, max_chat); err != nil {
|
go this.module.modelChat.sendChatToUnion(msg, max_chat)
|
||||||
code = pb.ErrorCode_DBError
|
|
||||||
return
|
|
||||||
}
|
|
||||||
break
|
break
|
||||||
case pb.ChatChannel_Private:
|
case pb.ChatChannel_Private:
|
||||||
if msg.Ctype == pb.ChatType_Text { //过滤敏感词
|
if msg.Ctype == pb.ChatType_Text { //过滤敏感词
|
||||||
@ -121,10 +115,7 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (code
|
|||||||
}
|
}
|
||||||
msg.ChannelId = userexpand.Chatchannel //指定频道
|
msg.ChannelId = userexpand.Chatchannel //指定频道
|
||||||
|
|
||||||
if err = this.module.modelChat.sendChatToCrossServer(msg, max_chat); err != nil {
|
go this.module.modelChat.sendChatToCrossServer(msg, max_chat)
|
||||||
code = pb.ErrorCode_DBError
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype106, 1)
|
this.module.ModuleRtask.SendToRtask(session, comm.Rtype106, 1)
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
|
@ -287,7 +287,7 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) (err error) {
|
|||||||
log.Field{Key: "serviceTag", Value: serviceTag},
|
log.Field{Key: "serviceTag", Value: serviceTag},
|
||||||
log.Field{Key: "servicePath", Value: servicePath},
|
log.Field{Key: "servicePath", Value: servicePath},
|
||||||
log.Field{Key: "servicePath", Value: servicePath},
|
log.Field{Key: "servicePath", Value: servicePath},
|
||||||
log.Field{Key: "req", Value: req.String()},
|
log.Field{Key: "req", Value: fmt.Sprintf("%s:%s %v", req.MainType, req.SubType, req.Message.String())},
|
||||||
log.Field{Key: "err", Value: err.Error()},
|
log.Field{Key: "err", Value: err.Error()},
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
@ -298,7 +298,7 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) (err error) {
|
|||||||
log.Field{Key: "uid", Value: this.uId},
|
log.Field{Key: "uid", Value: this.uId},
|
||||||
log.Field{Key: "serviceTag", Value: serviceTag},
|
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: "req", Value: fmt.Sprintf("%s:%s %v", req.MainType, req.SubType, req.Message.String())},
|
||||||
log.Field{Key: "err", Value: err.Error()},
|
log.Field{Key: "err", Value: err.Error()},
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
@ -307,7 +307,7 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) (err error) {
|
|||||||
this.gateway.Debug("[UserResponse]",
|
this.gateway.Debug("[UserResponse]",
|
||||||
log.Field{Key: "t", Value: time.Since(stime).Milliseconds()},
|
log.Field{Key: "t", Value: time.Since(stime).Milliseconds()},
|
||||||
log.Field{Key: "uid", Value: this.uId},
|
log.Field{Key: "uid", Value: this.uId},
|
||||||
log.Field{Key: "req", Value: req.String()},
|
log.Field{Key: "req", Value: fmt.Sprintf("%s:%s %v", req.MainType, req.SubType, req.Message.String())},
|
||||||
log.Field{Key: "reply", Value: reply.String()},
|
log.Field{Key: "reply", Value: reply.String()},
|
||||||
)
|
)
|
||||||
if reply.Code != pb.ErrorCode_Success {
|
if reply.Code != pb.ErrorCode_Success {
|
||||||
|
@ -29,6 +29,7 @@ var (
|
|||||||
gmpath string //服务列表下标
|
gmpath string //服务列表下标
|
||||||
crosspath string //服务列表下标
|
crosspath string //服务列表下标
|
||||||
sid string //服务列表下标
|
sid string //服务列表下标
|
||||||
|
onelog bool //日志路径
|
||||||
)
|
)
|
||||||
var confCmd = &cobra.Command{
|
var confCmd = &cobra.Command{
|
||||||
Use: "conf",
|
Use: "conf",
|
||||||
@ -78,6 +79,7 @@ func init() {
|
|||||||
RootCmd.PersistentFlags().StringVarP(&gmpath, "gm", "g", "./gm.json", "游戏区服配置")
|
RootCmd.PersistentFlags().StringVarP(&gmpath, "gm", "g", "./gm.json", "游戏区服配置")
|
||||||
RootCmd.PersistentFlags().StringVarP(&crosspath, "cross", "c", "./cross.json", "游戏跨服配置")
|
RootCmd.PersistentFlags().StringVarP(&crosspath, "cross", "c", "./cross.json", "游戏跨服配置")
|
||||||
RootCmd.PersistentFlags().StringVarP(&sid, "sid", "i", "", "区服id")
|
RootCmd.PersistentFlags().StringVarP(&sid, "sid", "i", "", "区服id")
|
||||||
|
RootCmd.PersistentFlags().BoolVarP(&onelog, "log", "l", false, "输出日志")
|
||||||
RootCmd.AddCommand(confCmd, startCmd, stopCmd, restart)
|
RootCmd.AddCommand(confCmd, startCmd, stopCmd, restart)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,11 +321,20 @@ func convertServiceSttings(config *comm.GameConfig, id int, stype string, ip str
|
|||||||
err = fmt.Errorf("服务类型异常 stype:%s", sseting.Type)
|
err = fmt.Errorf("服务类型异常 stype:%s", sseting.Type)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if !onelog {
|
||||||
sseting.Sys["log"] = map[string]interface{}{
|
sseting.Sys["log"] = map[string]interface{}{
|
||||||
"FileName": fmt.Sprintf("./log/%s.log", sseting.Id),
|
"FileName": fmt.Sprintf("./log/%s.log", sseting.Id),
|
||||||
"Loglevel": config.Loglevel,
|
"Loglevel": config.Loglevel,
|
||||||
"MaxAgeTime": config.MaxAgeTime,
|
"MaxAgeTime": config.MaxAgeTime,
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
sseting.Sys["log"] = map[string]interface{}{
|
||||||
|
"FileName": fmt.Sprintf("./log/%s.log", config.AreaId),
|
||||||
|
"Loglevel": config.Loglevel,
|
||||||
|
"MaxAgeTime": config.MaxAgeTime,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sseting.Sys["configure"] = map[string]interface{}{
|
sseting.Sys["configure"] = map[string]interface{}{
|
||||||
"ConfigurePath": "./json",
|
"ConfigurePath": "./json",
|
||||||
"TimestampFile": "./timestamp.text",
|
"TimestampFile": "./timestamp.text",
|
||||||
|
Loading…
Reference in New Issue
Block a user