From: Michael Date: Mon, 27 Feb 2023 07:02:06 +0000 (+0000) Subject: Use non static logger call X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=bd3120d6cb3b52cf103d4e2f36f0cd93d359d184;p=friendica.git Use non static logger call --- diff --git a/src/Core/Storage/Repository/StorageManager.php b/src/Core/Storage/Repository/StorageManager.php index fbe910d01d..252454665d 100644 --- a/src/Core/Storage/Repository/StorageManager.php +++ b/src/Core/Storage/Repository/StorageManager.php @@ -168,7 +168,7 @@ class StorageManager return $data['storage_config']; } catch (InternalServerErrorException $exception) { - throw new StorageException(sprintf('Failed calling hook::storage_config for backend %s', $name), $exception); + throw new StorageException(sprintf('Failed calling hook::storage_config for backend %s', $name), $exception->__toString()); } } } @@ -208,7 +208,7 @@ class StorageManager $this->backendInstances[$name] = new Type\SystemResource(); break; case Type\ExternalResource::getName(): - $this->backendInstances[$name] = new Type\ExternalResource(); + $this->backendInstances[$name] = new Type\ExternalResource($this->logger); break; default: $data = [ @@ -223,7 +223,7 @@ class StorageManager $this->backendInstances[$data['name'] ?? $name] = $data['storage']; } catch (InternalServerErrorException $exception) { - throw new StorageException(sprintf('Failed calling hook::storage_instance for backend %s', $name), $exception); + throw new StorageException(sprintf('Failed calling hook::storage_instance for backend %s', $name), $exception->__toString()); } break; } diff --git a/src/Core/Storage/Type/ExternalResource.php b/src/Core/Storage/Type/ExternalResource.php index 54d47e5bf4..181312a5bf 100644 --- a/src/Core/Storage/Type/ExternalResource.php +++ b/src/Core/Storage/Type/ExternalResource.php @@ -22,12 +22,12 @@ namespace Friendica\Core\Storage\Type; use Exception; -use Friendica\Core\Logger; use Friendica\Core\Storage\Exception\ReferenceStorageException; use Friendica\Core\Storage\Capability\ICanReadFromStorage; use Friendica\Network\HTTPClient\Client\HttpClientAccept; use Friendica\Network\HTTPClient\Client\HttpClientOptions; use Friendica\Util\HTTPSignature; +use Psr\Log\LoggerInterface; /** * External resource storage class @@ -39,6 +39,14 @@ class ExternalResource implements ICanReadFromStorage { const NAME = 'ExternalResource'; + /** @var LoggerInterface */ + protected $logger; + + public function __construct(LoggerInterface $logger) + { + $this->logger = $logger; + } + /** * @inheritDoc */ @@ -57,11 +65,11 @@ class ExternalResource implements ICanReadFromStorage try { $fetchResult = HTTPSignature::fetchRaw($data->url, $data->uid, [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::IMAGE]]); } catch (Exception $exception) { - Logger::notice('URL is invalid', ['url' => $data->url, 'error' => $exception]); + $this->logger->notice('URL is invalid', ['url' => $data->url, 'error' => $exception]); throw new ReferenceStorageException(sprintf('External resource failed to get %s', $reference), $exception->getCode(), $exception); } if (!empty($fetchResult) && $fetchResult->isSuccess()) { - Logger::debug('Got picture', ['Content-Type' => $fetchResult->getHeader('Content-Type'), 'uid' => $data->uid, 'url' => $data->url]); + $this->logger->debug('Got picture', ['Content-Type' => $fetchResult->getHeader('Content-Type'), 'uid' => $data->uid, 'url' => $data->url]); return $fetchResult->getBody(); } else { if (empty($fetchResult)) {