From bb2c2bb7f0aa57ad7e77a914fb341e2535801da9 Mon Sep 17 00:00:00 2001 From: fenn-cs Date: Tue, 28 Mar 2023 21:20:08 +0100 Subject: Replace ILogger method calls index.php This commit replaces more ILogger method calls with `Psr\Log\LoggerInterface` as we gradually move away from the custom ILogger. This commit aslo, sets the customPsrLogger to not depend on the database to `logfile` config value. Signed-off-by: fenn-cs --- index.php | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'index.php') diff --git a/index.php b/index.php index 7b62f17e5bd..f57cc03dd5e 100644 --- a/index.php +++ b/index.php @@ -29,13 +29,17 @@ * */ require_once __DIR__ . '/lib/versioncheck.php'; +use Psr\Log\LoggerInterface; try { require_once __DIR__ . '/lib/base.php'; OC::handleRequest(); } catch (\OC\ServiceUnavailableException $ex) { - \OC::$server->getLogger()->logException($ex, ['app' => 'index']); + \OC::$server->get(LoggerInterface::class)->error($ex->getMessage(), [ + 'app' => 'index', + 'exception' => $ex, + ]); //show the user a detailed error page OC_Template::printExceptionErrorPage($ex, 503); @@ -44,8 +48,14 @@ try { OC_Template::printErrorPage($ex->getMessage(), $ex->getHint(), 503); } catch (Exception $ex2) { try { - \OC::$server->getLogger()->logException($ex, ['app' => 'index']); - \OC::$server->getLogger()->logException($ex2, ['app' => 'index']); + \OC::$server->get(LoggerInterface::class)->error($ex->getMessage(), [ + 'app' => 'index', + 'exception' => $ex, + ]); + \OC::$server->get(LoggerInterface::class)->error($ex2->getMessage(), [ + 'app' => 'index', + 'exception' => $ex2, + ]); } catch (Throwable $e) { // no way to log it properly - but to avoid a white page of death we try harder and ignore this one here } @@ -68,13 +78,19 @@ try { } OC_Template::printErrorPage($ex->getMessage(), $ex->getMessage(), 401); } catch (Exception $ex) { - \OC::$server->getLogger()->logException($ex, ['app' => 'index']); + \OC::$server->get(LoggerInterface::class)->error($ex->getMessage(), [ + 'app' => 'index', + 'exception' => $ex, + ]); //show the user a detailed error page OC_Template::printExceptionErrorPage($ex, 500); } catch (Error $ex) { try { - \OC::$server->getLogger()->logException($ex, ['app' => 'index']); + \OC::$server->get(LoggerInterface::class)->error($ex->getMessage(), [ + 'app' => 'index', + 'exception' => $ex, + ]); } catch (Error $e) { http_response_code(500); header('Content-Type: text/plain; charset=utf-8'); -- cgit v1.2.3