Use non static logger call

This commit is contained in:
Michael 2023-02-27 07:02:06 +00:00
parent 6e3602591d
commit bd3120d6cb
2 changed files with 14 additions and 6 deletions

View File

@ -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;
}

View File

@ -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)) {