Skip to content

Commit

Permalink
Improved exception logging
Browse files Browse the repository at this point in the history
  • Loading branch information
sergix44 committed May 12, 2019
1 parent 67c9d82 commit de42f2e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion app/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function getUsedSpaceByUser($id): int
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]);
}
}

Expand Down
10 changes: 7 additions & 3 deletions bootstrap/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@
$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);

Expand Down Expand Up @@ -103,7 +107,7 @@

$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]);
};
};
Expand All @@ -119,7 +123,7 @@
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]);
};
};
Expand Down

0 comments on commit de42f2e

Please sign in to comment.