From e2531f8503dea904dd1cb389ca017ce7bda5ccfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 31 Mar 2022 15:34:57 +0200 Subject: Migrate dav application from ILogger to LoggerInterface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- apps/dav/lib/Connector/Sabre/File.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'apps/dav/lib/Connector/Sabre/File.php') diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php index 6c379984995..37fb109a3bd 100644 --- a/apps/dav/lib/Connector/Sabre/File.php +++ b/apps/dav/lib/Connector/Sabre/File.php @@ -63,11 +63,11 @@ use OCP\Files\NotPermittedException; use OCP\Files\Storage; use OCP\Files\StorageNotAvailableException; use OCP\IL10N; -use OCP\ILogger; use OCP\L10N\IFactory as IL10NFactory; use OCP\Lock\ILockingProvider; use OCP\Lock\LockedException; use OCP\Share\IManager; +use Psr\Log\LoggerInterface; use Sabre\DAV\Exception; use Sabre\DAV\Exception\BadRequest; use Sabre\DAV\Exception\Forbidden; @@ -251,7 +251,7 @@ class File extends Node implements IFile { } else { $target = $partStorage->fopen($internalPartPath, 'wb'); if ($target === false) { - \OC::$server->getLogger()->error('\OC\Files\Filesystem::fopen() failed', ['app' => 'webdav']); + \OC::$server->get(LoggerInterface::class)->error('\OC\Files\Filesystem::fopen() failed', ['app' => 'webdav']); // because we have no clue about the cause we can only throw back a 500/Internal Server Error throw new Exception($this->l10n->t('Could not write file contents')); } @@ -295,13 +295,12 @@ class File extends Node implements IFile { } } } catch (\Exception $e) { - $context = []; - if ($e instanceof LockedException) { - $context['level'] = ILogger::DEBUG; + \OC::$server->get(LoggerInterface::class)->debug($e->getMessage(), ['exception' => $e]); + } else { + \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), ['exception' => $e]); } - \OC::$server->getLogger()->logException($e, $context); if ($needsPartFile) { $partStorage->unlink($internalPartPath); } @@ -340,7 +339,7 @@ class File extends Node implements IFile { $renameOkay = $storage->moveFromStorage($partStorage, $internalPartPath, $internalPath); $fileExists = $storage->file_exists($internalPath); if ($renameOkay === false || $fileExists === false) { - \OC::$server->getLogger()->error('renaming part file to final file failed $renameOkay: ' . ($renameOkay ? 'true' : 'false') . ', $fileExists: ' . ($fileExists ? 'true' : 'false') . ')', ['app' => 'webdav']); + \OC::$server->get(LoggerInterface::class)->error('renaming part file to final file failed $renameOkay: ' . ($renameOkay ? 'true' : 'false') . ', $fileExists: ' . ($fileExists ? 'true' : 'false') . ')', ['app' => 'webdav']); throw new Exception($this->l10n->t('Could not rename part file to final file')); } } catch (ForbiddenException $ex) { @@ -626,7 +625,7 @@ class File extends Node implements IFile { $renameOkay = $targetStorage->moveFromStorage($partStorage, $partInternalPath, $targetInternalPath); $fileExists = $targetStorage->file_exists($targetInternalPath); if ($renameOkay === false || $fileExists === false) { - \OC::$server->getLogger()->error('\OC\Files\Filesystem::rename() failed', ['app' => 'webdav']); + \OC::$server->get(LoggerInterface::class)->error('\OC\Files\Filesystem::rename() failed', ['app' => 'webdav']); // only delete if an error occurred and the target file was already created if ($fileExists) { // set to null to avoid double-deletion when handling exception -- cgit v1.2.3