Added debug output to jsonrpc.go
This commit is contained in:
parent
a34a40cb12
commit
ef7bd74e4a
1 changed files with 8 additions and 0 deletions
|
|
@ -60,6 +60,10 @@ func (c *Client) call(ctx context.Context, method string, params interface{}, re
|
|||
return fmt.Errorf("failed to marshal request: %w", err)
|
||||
}
|
||||
|
||||
if c.logger != nil {
|
||||
c.logger.Debug("JSON-RPC request", "method", method, "body", string(body))
|
||||
}
|
||||
|
||||
httpReq, err := http.NewRequestWithContext(ctx, http.MethodPost, c.endpoint, bytes.NewReader(body))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create request: %w", err)
|
||||
|
|
@ -92,6 +96,10 @@ func (c *Client) call(ctx context.Context, method string, params interface{}, re
|
|||
return fmt.Errorf("failed to read response body: %w", err)
|
||||
}
|
||||
|
||||
if c.logger != nil {
|
||||
c.logger.Debug("JSON-RPC response", "method", method, "body", string(respBody))
|
||||
}
|
||||
|
||||
var rpcResp JSONRPCResponse
|
||||
if err := json.Unmarshal(respBody, &rpcResp); err != nil {
|
||||
return fmt.Errorf("failed to unmarshal response: %w", err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue