Merge pull request #429 from woocommerce/pcp-492-log

Do not log reference transactions checks
This commit is contained in:
Emili Castells 2022-01-11 10:04:12 +01:00 committed by GitHub
commit 9f623bdcd4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 6 deletions

View file

@ -120,11 +120,17 @@ class BillingAgreementsEndpoint {
*/
public function reference_transaction_enabled(): bool {
try {
$this->create_token(
'Checking if reference transactions are enabled',
'https://example.com/return',
'https://example.com/cancel'
);
$this->is_request_logging_enabled = false;
try {
$this->create_token(
'Checking if reference transactions are enabled',
'https://example.com/return',
'https://example.com/cancel'
);
} finally {
$this->is_request_logging_enabled = true;
}
return true;
} catch ( PayPalApiException $exception ) {

View file

@ -16,6 +16,13 @@ use WP_Error;
*/
trait RequestTrait {
/**
* Whether to log the detailed request/response info.
*
* @var bool
*/
protected $is_request_logging_enabled = true;
/**
* Performs a request
*
@ -39,7 +46,9 @@ trait RequestTrait {
}
$response = wp_remote_get( $url, $args );
$this->logger->debug( $this->request_response_string( $url, $args, $response ) );
if ( $this->is_request_logging_enabled ) {
$this->logger->debug( $this->request_response_string( $url, $args, $response ) );
}
return $response;
}