Skip to content

Commit

Permalink
Fix log print uid fmt string %d -> %s or %v.
Browse files Browse the repository at this point in the history
  • Loading branch information
Colstuwjx authored and felipejfc committed Sep 27, 2020
1 parent 2e8d171 commit 1461dd7
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,10 @@ func (a *Agent) Push(route string, v interface{}) error {

switch d := v.(type) {
case []byte:
logger.Log.Debugf("Type=Push, ID=%d, UID=%d, Route=%s, Data=%dbytes",
logger.Log.Debugf("Type=Push, ID=%d, UID=%s, Route=%s, Data=%dbytes",
a.Session.ID(), a.Session.UID(), route, len(d))
default:
logger.Log.Debugf("Type=Push, ID=%d, UID=%d, Route=%s, Data=%+v",
logger.Log.Debugf("Type=Push, ID=%d, UID=%s, Route=%s, Data=%+v",
a.Session.ID(), a.Session.UID(), route, v)
}
return a.send(pendingMessage{typ: message.Push, route: route, payload: v})
Expand All @@ -241,10 +241,10 @@ func (a *Agent) ResponseMID(ctx context.Context, mid uint, v interface{}, isErro

switch d := v.(type) {
case []byte:
logger.Log.Debugf("Type=Response, ID=%d, UID=%d, MID=%d, Data=%dbytes",
logger.Log.Debugf("Type=Response, ID=%d, UID=%s, MID=%d, Data=%dbytes",
a.Session.ID(), a.Session.UID(), mid, len(d))
default:
logger.Log.Infof("Type=Response, ID=%d, UID=%d, MID=%d, Data=%+v",
logger.Log.Infof("Type=Response, ID=%d, UID=%s, MID=%d, Data=%+v",
a.Session.ID(), a.Session.UID(), mid, v)
}

Expand Down Expand Up @@ -321,7 +321,7 @@ func (a *Agent) SetStatus(state int32) {
func (a *Agent) Handle() {
defer func() {
a.Close()
logger.Log.Debugf("Session handle goroutine exit, SessionID=%d, UID=%d", a.Session.ID(), a.Session.UID())
logger.Log.Debugf("Session handle goroutine exit, SessionID=%d, UID=%s", a.Session.ID(), a.Session.UID())
}()

go a.write()
Expand Down
4 changes: 2 additions & 2 deletions agent/agent_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ func (a *Remote) Push(route string, v interface{}) error {
}
switch d := v.(type) {
case []byte:
logger.Log.Debugf("Type=Push, ID=%d, UID=%d, Route=%s, Data=%dbytes",
logger.Log.Debugf("Type=Push, ID=%d, UID=%s, Route=%s, Data=%dbytes",
a.Session.ID(), a.Session.UID(), route, len(d))
default:
logger.Log.Debugf("Type=Push, ID=%d, UID=%d, Route=%s, Data=%+v",
logger.Log.Debugf("Type=Push, ID=%d, UID=%s, Route=%s, Data=%+v",
a.Session.ID(), a.Session.UID(), route, v)
}

Expand Down
6 changes: 3 additions & 3 deletions group.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func GroupBroadcast(ctx context.Context, frontendType, groupName, route string,
func sendDataToMembers(uids []string, frontendType, route string, v interface{}) error {
errUids, err := SendPushToUsers(route, v, uids, frontendType)
if err != nil {
logger.Log.Errorf("Group push message error, UID=%d, Error=%s", errUids, err.Error())
logger.Log.Errorf("Group push message error, UID=%v, Error=%s", errUids, err.Error())
return err
}
return nil
Expand All @@ -93,13 +93,13 @@ func GroupAddMember(ctx context.Context, groupName, uid string) error {
if uid == "" {
return constants.ErrEmptyUID
}
logger.Log.Debugf("Add user to group %s, UID=%d", groupName, uid)
logger.Log.Debugf("Add user to group %s, UID=%s", groupName, uid)
return groupServiceInstance.GroupAddMember(ctx, groupName, uid)
}

// GroupRemoveMember removes specified UID from group
func GroupRemoveMember(ctx context.Context, groupName, uid string) error {
logger.Log.Debugf("Remove user from group %s, UID=%d", groupName, uid)
logger.Log.Debugf("Remove user from group %s, UID=%s", groupName, uid)
return groupServiceInstance.GroupRemoveMember(ctx, groupName, uid)
}

Expand Down
4 changes: 2 additions & 2 deletions kick.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ func SendKickToUsers(uids []string, frontendType string) ([]string, error) {
if s := session.GetSessionByUID(uid); s != nil {
if err := s.Kick(context.Background()); err != nil {
notKickedUids = append(notKickedUids, uid)
logger.Log.Errorf("Session kick error, ID=%d, UID=%d, ERROR=%s", s.ID(), s.UID(), err.Error())
logger.Log.Errorf("Session kick error, ID=%d, UID=%s, ERROR=%s", s.ID(), s.UID(), err.Error())
}
} else if app.rpcClient != nil {
kick := &protos.KickMsg{UserId: uid}
if err := app.rpcClient.SendKick(uid, frontendType, kick); err != nil {
notKickedUids = append(notKickedUids, uid)
logger.Log.Errorf("RPCClient send kick error, UID=%d, SvType=%s, Error=%s", uid, frontendType, err.Error())
logger.Log.Errorf("RPCClient send kick error, UID=%s, SvType=%s, Error=%s", uid, frontendType, err.Error())
}
} else {
notKickedUids = append(notKickedUids, uid)
Expand Down
2 changes: 1 addition & 1 deletion push.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func SendPushToUsers(route string, v interface{}, uids []string, frontendType st
if s := session.GetSessionByUID(uid); s != nil && app.server.Type == frontendType {
if err := s.Push(route, data); err != nil {
notPushedUids = append(notPushedUids, uid)
logger.Log.Errorf("Session push message error, ID=%d, UID=%d, Error=%s",
logger.Log.Errorf("Session push message error, ID=%d, UID=%s, Error=%s",
s.ID(), s.UID(), err.Error())
}
} else if app.rpcClient != nil {
Expand Down
2 changes: 1 addition & 1 deletion service/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (h *HandlerService) Handle(conn acceptor.PlayerConn) {
// guarantee agent related resource is destroyed
defer func() {
a.Session.Close()
logger.Log.Debugf("Session read goroutine exit, SessionID=%d, UID=%d", a.Session.ID(), a.Session.UID())
logger.Log.Debugf("Session read goroutine exit, SessionID=%d, UID=%s", a.Session.ID(), a.Session.UID())
}()

for {
Expand Down

0 comments on commit 1461dd7

Please sign in to comment.