Added debug output to jsonrpc.go

This commit is contained in:
Oliver Jakoubek 2026-01-23 11:42:11 +01:00
commit ef7bd74e4a

View file

@ -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) 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)) httpReq, err := http.NewRequestWithContext(ctx, http.MethodPost, c.endpoint, bytes.NewReader(body))
if err != nil { if err != nil {
return fmt.Errorf("failed to create request: %w", err) 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) 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 var rpcResp JSONRPCResponse
if err := json.Unmarshal(respBody, &rpcResp); err != nil { if err := json.Unmarshal(respBody, &rpcResp); err != nil {
return fmt.Errorf("failed to unmarshal response: %w", err) return fmt.Errorf("failed to unmarshal response: %w", err)