Log request body and wp error

This commit is contained in:
dinamiko 2021-09-13 15:38:34 +02:00
parent 1eb2087bfb
commit ba66cf6c2e

View file

@ -43,17 +43,22 @@ trait RequestTrait {
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( $args['body'] ) ) {
$this->logger->log( 'info', 'Request Body: ' . wc_print_r( $args['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 ) );
if ( ! is_wp_error( $response ) ) {
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 ) );
}
} else {
$this->logger->log( 'error', 'WP Error: ' . wc_print_r( $response->get_error_code() . ' ' . $response->get_error_message(), true ) );
}
return $response;