-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev/sofort-deprecation' of github.com:Automattic/woocom…
…merce-payments into dev/sofort-deprecation
- Loading branch information
Showing
11 changed files
with
461 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: minor | ||
Type: add | ||
|
||
Added an internal logger class, meant for use by classes within src. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: fix | ||
|
||
Fix Documents page loading on WooCommerce 8.2.0. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: fix | ||
|
||
Limit early WooPay session requests based on feature flag. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
<?php | ||
/** | ||
* Class Logger | ||
* | ||
* @package WooCommerce\Payments | ||
*/ | ||
|
||
namespace WCPay\Internal; | ||
|
||
use Exception; | ||
use WC_Logger; | ||
use WC_Log_Levels; | ||
use WC_Payment_Gateway_WCPay; | ||
use WCPay\Core\Mode; | ||
|
||
/** | ||
* A wrapper class for interacting with WC_Logger. | ||
*/ | ||
class Logger { | ||
|
||
const LOG_FILENAME = 'woocommerce-payments'; | ||
|
||
/** | ||
* The holding property for our WC_Logger instance. | ||
* | ||
* @var WC_Logger $logger | ||
*/ | ||
private $wc_logger; | ||
|
||
/** | ||
* Mode | ||
* | ||
* @var Mode | ||
*/ | ||
private $mode; | ||
|
||
/** | ||
* WC_Payment_Gateway_WCPay | ||
* | ||
* @var WC_Payment_Gateway_WCPay | ||
*/ | ||
private $gateway; | ||
|
||
/** | ||
* Logger constructor. | ||
* | ||
* @param WC_Logger $wc_logger WC_Logger. | ||
* @param Mode $mode Mode. | ||
* @param WC_Payment_Gateway_WCPay $gateway WC_Payment_Gateway_WCPay. | ||
*/ | ||
public function __construct( WC_Logger $wc_logger, Mode $mode, WC_Payment_Gateway_WCPay $gateway ) { | ||
$this->wc_logger = $wc_logger; | ||
$this->mode = $mode; | ||
$this->gateway = $gateway; | ||
} | ||
|
||
/** | ||
* Add a log entry. | ||
* | ||
* Note that this depends on WC_Payments gateway property to be initialized as | ||
* we need this to access the plugins debug setting to figure out if the setting | ||
* is turned on. | ||
* | ||
* @param string $message Log message. | ||
* @param string $level One of the following: | ||
* 'emergency': System is unusable. | ||
* 'alert': Action must be taken immediately. | ||
* 'critical': Critical conditions. | ||
* 'error': Error conditions. | ||
* 'warning': Warning conditions. | ||
* 'notice': Normal but significant condition. | ||
* 'info': Informational messages. | ||
* 'debug': Debug-level messages. | ||
*/ | ||
public function log( $message, $level = 'info' ) : void { | ||
if ( ! $this->can_log() ) { | ||
return; | ||
} | ||
$this->wc_logger->log( $level, $message, [ 'source' => self::LOG_FILENAME ] ); | ||
} | ||
|
||
/** | ||
* Checks if the gateway setting logging toggle is enabled. | ||
* | ||
* @return bool Depending on the enable_logging setting. | ||
*/ | ||
public function can_log() { | ||
try { | ||
if ( $this->mode->is_dev() ) { | ||
return true; | ||
} | ||
} catch ( Exception $e ) { | ||
return false; | ||
} | ||
return 'yes' === $this->gateway->get_option( 'enable_logging' ); | ||
} | ||
|
||
/** | ||
* Creates a log entry of type emergency | ||
* | ||
* @param string $message To send to the log file. | ||
*/ | ||
public function emergency( $message ) : void { | ||
$this->log( $message, WC_Log_Levels::EMERGENCY ); | ||
} | ||
|
||
/** | ||
* Creates a log entry of type alert | ||
* | ||
* @param string $message To send to the log file. | ||
*/ | ||
public function alert( $message ) : void { | ||
$this->log( $message, WC_Log_Levels::ALERT ); | ||
} | ||
|
||
/** | ||
* Creates a log entry of type critical | ||
* | ||
* @param string $message To send to the log file. | ||
*/ | ||
public function critical( $message ) : void { | ||
$this->log( $message, WC_Log_Levels::CRITICAL ); | ||
} | ||
|
||
/** | ||
* Creates a log entry of type error | ||
* | ||
* @param string $message To send to the log file. | ||
*/ | ||
public function error( $message ) : void { | ||
$this->log( $message, WC_Log_Levels::ERROR ); | ||
} | ||
|
||
/** | ||
* Creates a log entry of type warning | ||
* | ||
* @param string $message To send to the log file. | ||
*/ | ||
public function warning( $message ) : void { | ||
$this->log( $message, WC_Log_Levels::WARNING ); | ||
} | ||
|
||
/** | ||
* Creates a log entry of type notice | ||
* | ||
* @param string $message To send to the log file. | ||
*/ | ||
public function notice( $message ) : void { | ||
$this->log( $message, WC_Log_Levels::NOTICE ); | ||
} | ||
|
||
/** | ||
* Creates a log entry of type info | ||
* | ||
* @param string $message To send to the log file. | ||
*/ | ||
public function info( $message ) : void { | ||
$this->log( $message, WC_Log_Levels::INFO ); | ||
} | ||
|
||
/** | ||
* Creates a log entry of type debug | ||
* | ||
* @param string $message To send to the log file. | ||
*/ | ||
public function debug( $message ) : void { | ||
$this->log( $message, WC_Log_Levels::DEBUG ); | ||
} | ||
} |
Oops, something went wrong.