refactor: Migrate away from deprecated ILogger interface to PSR-3

Mostly replace `ILogger` with `LoggerInterface` and some minor cleanup (constructor property promotion).
Some places used the deprecated `logException` this is easy to migrate by simply use the appropriate loglevel on the logger
and place the exception under the `exception` key in the context.
Also the manual checking of the configured log level is not needed, as this is already done by the logger.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
Ferdinand Thiessen
2024-08-19 13:48:49 +02:00
parent 3e1805b09b
commit beb563e74e
9 changed files with 75 additions and 142 deletions

View File

@@ -20,37 +20,21 @@ use OCP\Files\SimpleFS\ISimpleFile;
use OCP\Files\SimpleFS\ISimpleFolder;
use OCP\IConfig;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IRequest;
use Psr\Log\LoggerInterface;
class FileService implements IAttachmentService {
private $l10n;
private $appData;
private $request;
private $logger;
private $rootFolder;
private $config;
private $attachmentMapper;
private $mimeTypeDetector;
public function __construct(
IL10N $l10n,
IAppData $appData,
IRequest $request,
ILogger $logger,
IRootFolder $rootFolder,
IConfig $config,
AttachmentMapper $attachmentMapper,
IMimeTypeDetector $mimeTypeDetector
private IL10N $l10n,
private IAppData $appData,
private IRequest $request,
private LoggerInterface $logger,
private IRootFolder $rootFolder,
private IConfig $config,
private AttachmentMapper $attachmentMapper,
private IMimeTypeDetector $mimeTypeDetector
) {
$this->l10n = $l10n;
$this->appData = $appData;
$this->request = $request;
$this->logger = $logger;
$this->rootFolder = $rootFolder;
$this->config = $config;
$this->attachmentMapper = $attachmentMapper;
$this->mimeTypeDetector = $mimeTypeDetector;
}
/**
@@ -193,6 +177,7 @@ class FileService implements IAttachmentService {
/**
* Workaround until ISimpleFile can be fetched as a resource
*
* @return \OCP\Files\File
* @throws \Exception
*/
private function getFileFromRootFolder(Attachment $attachment) {