diff --git a/classes/mutex/RedisMutex.php b/classes/mutex/RedisMutex.php index 6732ce54..90af55d4 100644 --- a/classes/mutex/RedisMutex.php +++ b/classes/mutex/RedisMutex.php @@ -7,7 +7,7 @@ use malkusch\lock\exception\LockAcquireException; use malkusch\lock\exception\LockReleaseException; use Psr\Log\LoggerAwareInterface; -use Psr\Log\LoggerInterface; +use Psr\Log\LoggerAwareTrait; use Psr\Log\NullLogger; /** @@ -21,6 +21,8 @@ */ abstract class RedisMutex extends SpinlockMutex implements LoggerAwareInterface { + use LoggerAwareTrait; + /** * @var string The random value token for key identification. */ @@ -31,11 +33,6 @@ abstract class RedisMutex extends SpinlockMutex implements LoggerAwareInterface */ private $redisAPIs; - /** - * @var LoggerInterface The logger. - */ - private $logger; - /** * Sets the Redis APIs. * @@ -53,21 +50,6 @@ public function __construct(array $redisAPIs, string $name, int $timeout = 3) $this->logger = new NullLogger(); } - /** - * Sets a logger instance on the object - * - * RedLock is a fault tolerant lock algorithm. I.e. it does tolerate - * failing redis connections without breaking. If you want to get notified - * about such events you'll have to provide a logger. Those events will - * be logged as warnings. - * - * @param LoggerInterface $logger The logger. - */ - public function setLogger(LoggerInterface $logger) - { - $this->logger = $logger; - } - protected function acquire(string $key, int $expire): bool { // 1. This differs from the specification to avoid an overflow on 32-Bit systems. diff --git a/composer.json b/composer.json index 73d571a8..22977325 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,7 @@ }, "require": { "php": "^7.2 || ^8.0", - "psr/log": "^1" + "psr/log": "^1|^2|^3" }, "require-dev": { "ext-memcached": "*",