From de42f2e8bf3f2e9d3c426680d45058b20ab43995 Mon Sep 17 00:00:00 2001 From: Sergio Brighenti Date: Sun, 12 May 2019 15:52:26 +0200 Subject: [PATCH] Improved exception logging --- CHANGELOG.md | 5 +++++ app/Controllers/Controller.php | 2 +- bootstrap/app.php | 10 +++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 167d1d8..c8a41da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.5.3 ++ Fixed bad css loading on Firefox (#35). ++ Fixed wrong style for publish/unpublish button. ++ Improved exception stacktrace logging. + ## v2.5.2 + Improved session handling. + Fixed telegram share not working. diff --git a/app/Controllers/Controller.php b/app/Controllers/Controller.php index b116fc6..42942e8 100644 --- a/app/Controllers/Controller.php +++ b/app/Controllers/Controller.php @@ -53,7 +53,7 @@ abstract class Controller try { $totalSize += $filesystem->getSize($media->storage_path); } catch (FileNotFoundException $e) { - $this->logger->error('Error calculating file size', [$e->getTraceAsString()]); + $this->logger->error('Error calculating file size', ['exception' => $e]); } } diff --git a/bootstrap/app.php b/bootstrap/app.php index 0e2346c..b50fde4 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -53,7 +53,11 @@ $container['logger'] = function ($container) { $logger = new Logger('app'); $streamHandler = new RotatingFileHandler(BASE_DIR . 'logs/log.txt', 10, Logger::DEBUG); - $streamHandler->setFormatter(new LineFormatter("[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n", "Y-m-d H:i:s", true)); + + $lineFormatter = new LineFormatter("[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n", "Y-m-d H:i:s"); + $lineFormatter->includeStacktraces(true); + + $streamHandler->setFormatter($lineFormatter); $logger->pushHandler($streamHandler); @@ -103,7 +107,7 @@ $container['view'] = function ($container) use (&$config) { $container['phpErrorHandler'] = function ($container) { return function (Request $request, Response $response, Throwable $error) use (&$container) { - $container->logger->critical('Fatal runtime error during app execution', [$error, $error->getTraceAsString()]); + $container->logger->critical('Fatal runtime error during app execution', ['exception' => $error]); return $container->view->render($response->withStatus(500), 'errors/500.twig', ['exception' => $error]); }; }; @@ -119,7 +123,7 @@ $container['errorHandler'] = function ($container) { return $container->view->render($response->withStatus(403), 'errors/403.twig'); } - $container->logger->critical('Fatal exception during app execution', [$exception, $exception->getTraceAsString()]); + $container->logger->critical('Fatal exception during app execution', ['exception' => $exception]); return $container->view->render($response->withStatus(500), 'errors/500.twig', ['exception' => $exception]); }; };