Skip to content

Commit

Permalink
Merge pull request #1 from qlcchain/feature/log-req-and-resp
Browse files Browse the repository at this point in the history
feat: log request and response message
  • Loading branch information
zengchen221 authored Mar 12, 2020
2 parents 0141c44 + 5106220 commit aaf566c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ func (c *Client) CallContext(ctx context.Context, result interface{}, method str
if err != nil {
return err
}
logger.Debug("req: ", msg)
op := &requestOp{ids: []json.RawMessage{msg.ID}, resp: make(chan *jsonrpcMessage, 1)}

if c.isHTTP {
Expand All @@ -297,6 +298,11 @@ func (c *Client) CallContext(ctx context.Context, result interface{}, method str
case len(resp.Result) == 0:
return ErrNoResult
default:
if IsDebug {
if r, err := json.Marshal(resp.Result); err == nil {
logger.Debug("resp: ", string(r))
}
}
return json.Unmarshal(resp.Result, &result)
}
}
Expand Down

0 comments on commit aaf566c

Please sign in to comment.