From e1d324f7ebb311b1e0ed094ec13de43163d7cc68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 1 Dec 2022 11:21:57 +0100 Subject: [PATCH] Migrate lib/base.php to LoggerInterface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- lib/base.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/base.php b/lib/base.php index b216ef86f9b..751e6c305fb 100644 --- a/lib/base.php +++ b/lib/base.php @@ -78,6 +78,7 @@ use OCP\IUserSession; use OCP\Server; use OCP\Share; use OCP\User\Events\UserChangedEvent; +use Psr\Log\LoggerInterface; use function OCP\Log\logger; require_once 'public/Constants.php'; @@ -439,7 +440,7 @@ class OC { // if session can't be started break with http 500 error } catch (Exception $e) { - \OC::$server->getLogger()->logException($e, ['app' => 'base']); + Server::get(LoggerInterface::class)->error($e->getMessage(), ['app' => 'base','exception' => $e]); //show the user a detailed error page OC_Template::printExceptionErrorPage($e, 500); die(); @@ -810,8 +811,7 @@ class OC { if (!$isScssRequest) { http_response_code(400); - - \OC::$server->getLogger()->info( + Server::get(LoggerInterface::class)->info( 'Trusted domain error. "{remoteAddress}" tried to access using "{host}" as host.', [ 'app' => 'core', @@ -864,10 +864,9 @@ class OC { } catch (\Exception $e) { // a GC exception should not prevent users from using OC, // so log the exception - \OC::$server->getLogger()->logException($e, [ - 'message' => 'Exception when running cache gc.', - 'level' => ILogger::WARN, + Server::get(LoggerInterface::class)->warning('Exception when running cache gc.', [ 'app' => 'core', + 'exception' => $e, ]); } });