From 1eb2087bfbb4e8d0fbd63a195f0f6b11f9c56aad Mon Sep 17 00:00:00 2001 From: dinamiko Date: Mon, 13 Sep 2021 13:38:58 +0200 Subject: [PATCH] Log request and response information --- .../src/Endpoint/class-requesttrait.php | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/modules/ppcp-api-client/src/Endpoint/class-requesttrait.php b/modules/ppcp-api-client/src/Endpoint/class-requesttrait.php index 7066f13b1..73dc2df94 100644 --- a/modules/ppcp-api-client/src/Endpoint/class-requesttrait.php +++ b/modules/ppcp-api-client/src/Endpoint/class-requesttrait.php @@ -36,6 +36,26 @@ trait RequestTrait { $args['headers']['PayPal-Partner-Attribution-Id'] = 'Woo_PPCP'; } - return wp_remote_get( $url, $args ); + $response = wp_remote_get( $url, $args ); + + $this->logger->log( 'info', '--------------------------------------------------------------------' ); + $this->logger->log( 'info', 'URL: ' . wc_print_r( $url, true ) ); + if ( isset( $args['method'] ) ) { + $this->logger->log( 'info', 'Method: ' . wc_print_r( $args['method'], true ) ); + } + if ( isset( $args['headers']['body'] ) ) { + $this->logger->log( 'info', 'Request Body: ' . wc_print_r( $args['headers']['body'], true ) ); + } + if ( isset( $response['headers']->getAll()['paypal-debug-id'] ) ) { + $this->logger->log( 'info', 'Response Debug ID: ' . wc_print_r( $response['headers']->getAll()['paypal-debug-id'], true ) ); + } + if ( isset( $response['response'] ) ) { + $this->logger->log( 'info', 'Response: ' . wc_print_r( $response['response'], true ) ); + } + if ( isset( $response['body'] ) ) { + $this->logger->log( 'info', 'Response Body: ' . wc_print_r( $response['body'], true ) ); + } + + return $response; } }