Skip to content

Commit

Permalink
feat: Cmd2Value carry caller
Browse files Browse the repository at this point in the history
  • Loading branch information
withchao committed Sep 27, 2024
1 parent 5b64e79 commit d3ede48
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions internal/conversation_msg/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ func (c *Conversation) getConversationLatestMsgClientID(latestMsg string) string
}

func (c *Conversation) doUpdateConversation(c2v common.Cmd2Value) {
if c2v.Caller == "" {
c2v.Caller = common.GetCaller(3)
}
ctx := c2v.Ctx
node := c2v.Value.(common.UpdateConNode)
log.ZInfo(ctx, "doUpdateConversation", "node", node)
Expand Down
6 changes: 3 additions & 3 deletions pkg/common/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type Cmd2Value struct {

func sendCmd(ch chan<- Cmd2Value, value Cmd2Value, timeout time.Duration) error {
if value.Caller == "" {
value.Caller = getFuncName()
value.Caller = GetCaller(3)
}
log.ZDebug(value.Ctx, "sendCmd chan success", "caller", value.Caller, "cmd", value.Cmd, "value", value.Value)
if ch == nil {
Expand All @@ -51,8 +51,8 @@ func sendCmd(ch chan<- Cmd2Value, value Cmd2Value, timeout time.Duration) error
}
}

func getFuncName() string {
pc, _, line, ok := runtime.Caller(3)
func GetCaller(skip int) string {
pc, _, line, ok := runtime.Caller(skip)
if !ok {
return "runtime.caller.failed"
}
Expand Down

0 comments on commit d3ede48

Please sign in to comment.