diff --git a/src/Response/HttpResponse.php b/src/Response/HttpResponse.php index 6865e53..2f22d1b 100644 --- a/src/Response/HttpResponse.php +++ b/src/Response/HttpResponse.php @@ -1,5 +1,6 @@ dbConnection->rollback(); + $this->writeErrorLog($exception); $this->render500($exception); return; } @@ -151,4 +153,15 @@ class HttpResponse } return $url; } + + private function writeErrorLog(Exception $exception): void + { + if (!isset($this->appConfig['errorLogFile'])) { + return; + } + + $logFileHandler = fopen($this->appConfig['errorLogFile'], 'a'); + fwrite($logFileHandler, '[' . (new DateTime())->format('c') . '] ' . (string)$exception . PHP_EOL); + fclose($logFileHandler); + } }