diff --git a/lib/private/legacy/OC_Template.php b/lib/private/legacy/OC_Template.php index 422709cec7d7c..47803041cb55c 100644 --- a/lib/private/legacy/OC_Template.php +++ b/lib/private/legacy/OC_Template.php @@ -9,6 +9,7 @@ use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent; use OCP\AppFramework\Http\TemplateResponse; use OCP\EventDispatcher\IEventDispatcher; +use Psr\Log\LoggerInterface; require_once __DIR__.'/template/functions.php'; @@ -242,10 +243,10 @@ public static function printErrorPage($error_msg, $hint = '', $statusCode = 500) \OC::$server->get(IEventDispatcher::class)->dispatchTyped($event); print($response->render()); } catch (\Throwable $e1) { - $logger = \OC::$server->getLogger(); - $logger->logException($e1, [ + $logger = \OCP\Server::get(LoggerInterface::class); + $logger->error('Rendering themed error page failed. Falling back to un-themed error page.', [ 'app' => 'core', - 'message' => 'Rendering themed error page failed. Falling back to unthemed error page.' + 'exception' => $e1, ]); try { @@ -256,9 +257,9 @@ public static function printErrorPage($error_msg, $hint = '', $statusCode = 500) } catch (\Exception $e2) { // If nothing else works, fall back to plain text error page $logger->error("$error_msg $hint", ['app' => 'core']); - $logger->logException($e2, [ + $logger->error('Rendering un-themed error page failed. Falling back to plain text error page.', [ 'app' => 'core', - 'message' => 'Rendering unthemed error page failed. Falling back to plain text error page.' + 'exception' => $e2, ]); header('Content-Type: text/plain; charset=utf-8'); @@ -296,9 +297,9 @@ public static function printExceptionErrorPage($exception, $statusCode = 503) { $content->printPage(); } catch (\Exception $e) { try { - $logger = \OC::$server->getLogger(); - $logger->logException($exception, ['app' => 'core']); - $logger->logException($e, ['app' => 'core']); + $logger = \OCP\Server::get(LoggerInterface::class); + $logger->error($exception->getMessage(), ['app' => 'core', 'exception' => $exception]); + $logger->error($e->getMessage(), ['app' => 'core', 'exception' => $e]); } catch (Throwable $e) { // no way to log it properly - but to avoid a white page of death we send some output self::printPlainErrorPage($e, $debug);