Skip to content

Commit

Permalink
Updates DecaLog SDK from version 4.1.0 to version 5.0.0
Browse files Browse the repository at this point in the history
Pierre-Lannoy committed May 28, 2024

Verified

This commit was signed with the committer’s verified signature.
Pierre-Lannoy Pierre Lannoy
1 parent 0731224 commit 37781b1
Showing 3 changed files with 31 additions and 12 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,17 @@ All notable changes to **Sessions** are documented in this *changelog*.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and **Sessions** adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.0.0] - 2024-05-xx

### Added
- [BC] To enable installation on more heterogeneous platforms, the plugin now adapts its internal logging mode to already loaded libraries.

### Changed
- Updated DecaLog SDK from version 4.1.0 to version 5.0.0.

### Fixed
- PHP error with some plugins like Woocommerce Paypal Payments.

## [2.14.0] - 2024-05-07

### Changed
30 changes: 19 additions & 11 deletions includes/libraries/decalog-sdk/Engine.php
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ class Engine {
* @since 1.0.0
* @var string $version Maintains the engine version.
*/
private static $version = '4.2.0';
private static $version = '5.0.0';

/**
* The logger instances and parameters.
@@ -89,19 +89,27 @@ public static function getSdkVersion() {
* @since 4.2.0
*/
public static function getPsrVersion() {
if ( class_exists( '\Psr\Log\NullLogger') ) {
$reflection = new \ReflectionMethod(\Psr\Log\NullLogger::class, 'log');
foreach ( $reflection->getParameters() as $param ) {
if ( 'message' === $param->getName() ) {
if ( str_contains($param->getType() ?? '', '|') ) {
return 3;
$required = 1;
if ( ! defined( 'DECALOG_PSR_LOG_VERSION') ) {
define( 'DECALOG_PSR_LOG_VERSION', 'V1' );
}
switch ( strtolower( DECALOG_PSR_LOG_VERSION ) ) {
case 'v3':
$required = 3;
break;
case 'auto':
if ( class_exists( '\Psr\Log\NullLogger') ) {
$reflection = new \ReflectionMethod(\Psr\Log\NullLogger::class, 'log');
foreach ( $reflection->getParameters() as $param ) {
if ( 'message' === $param->getName() ) {
if ( str_contains($param->getType() ?? '', '|') ) {
$required = 3;
}
}
}
}
}
} else {
return 0;
}
return 1;
return $required;
}

/**
2 changes: 1 addition & 1 deletion includes/libraries/decalog-sdk/EventsLogger.php
Original file line number Diff line number Diff line change
@@ -266,7 +266,7 @@ public function log( $level, string|\Stringable $message, array $context = [] ):
}
}

} else { // if version in not detected or equal to 1
} else {

/**
* DecaLog PSR-3 logger class. Failsafe for old PSR-3 versions.

0 comments on commit 37781b1

Please sign in to comment.