From 74923d174bcf5ec4f9484de9f51bf55141b5918b Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Sun, 15 Sep 2024 01:45:51 +0200 Subject: refactor(OC_Files): Remove deprecated ILogger Signed-off-by: Ferdinand Thiessen --- lib/private/legacy/OC_Files.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/private/legacy/OC_Files.php b/lib/private/legacy/OC_Files.php index 8e23d70c690..126472e3061 100644 --- a/lib/private/legacy/OC_Files.php +++ b/lib/private/legacy/OC_Files.php @@ -7,12 +7,14 @@ */ use bantu\IniGetWrapper\IniGetWrapper; use OC\Files\View; +use OC\HintException; use OC\Streamer; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\Events\BeforeDirectFileDownloadEvent; use OCP\Files\Events\BeforeZipCreatedEvent; use OCP\Files\IRootFolder; use OCP\Lock\ILockingProvider; +use Psr\Log\LoggerInterface; /** * Class for file server access @@ -165,7 +167,7 @@ class OC_Files { $fileTime = $file->getMTime(); } else { // File is not a file? … - \OC::$server->getLogger()->debug( + \OCP\Server::get(LoggerInterface::class)->debug( 'File given, but no Node available. Name {file}', [ 'app' => 'files', 'file' => $file ] ); @@ -186,25 +188,25 @@ class OC_Files { self::unlockAllTheFiles($dir, $files, $getType, $view, $filename); } catch (\OCP\Lock\LockedException $ex) { self::unlockAllTheFiles($dir, $files, $getType, $view, $filename); - OC::$server->getLogger()->logException($ex); + \OCP\Server::get(LoggerInterface::class)->error('File is currently busy', ['exception' => $ex]); $l = \OC::$server->getL10N('lib'); - $hint = method_exists($ex, 'getHint') ? $ex->getHint() : ''; + $hint = $ex instanceof HintException ? $ex->getHint() : ''; \OC_Template::printErrorPage($l->t('File is currently busy, please try again later'), $hint, 200); } catch (\OCP\Files\ForbiddenException $ex) { self::unlockAllTheFiles($dir, $files, $getType, $view, $filename); - OC::$server->getLogger()->logException($ex); + \OCP\Server::get(LoggerInterface::class)->error('Cannot download file', ['exception' => $ex]); $l = \OC::$server->getL10N('lib'); \OC_Template::printErrorPage($l->t('Cannot download file'), $ex->getMessage(), 200); } catch (\OCP\Files\ConnectionLostException $ex) { self::unlockAllTheFiles($dir, $files, $getType, $view, $filename); - OC::$server->getLogger()->logException($ex, ['level' => \OCP\ILogger::DEBUG]); + \OCP\Server::get(LoggerInterface::class)->debug('Connection lost', ['exception' => $ex]); /* We do not print anything here, the connection is already closed */ die(); } catch (\Exception $ex) { self::unlockAllTheFiles($dir, $files, $getType, $view, $filename); - OC::$server->getLogger()->logException($ex); + \OCP\Server::get(LoggerInterface::class)->error('Cannot download file', ['exception' => $ex]); $l = \OC::$server->getL10N('lib'); - $hint = method_exists($ex, 'getHint') ? $ex->getHint() : ''; + $hint = $ex instanceof HintException ? $ex->getHint() : ''; if ($event && $event->getErrorMessage() !== null) { $hint .= ' ' . $event->getErrorMessage(); } -- cgit v1.2.3