log erros into file
This commit is contained in:
parent
ebe1fa2aa6
commit
d0bea80bbc
@ -1,5 +1,6 @@
|
|||||||
<?php namespace SokoWeb\Response;
|
<?php namespace SokoWeb\Response;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Exception;
|
use Exception;
|
||||||
use SokoWeb\Interfaces\Response\IRedirect;
|
use SokoWeb\Interfaces\Response\IRedirect;
|
||||||
@ -94,6 +95,7 @@ class HttpResponse
|
|||||||
$response = call_user_func([$controller, $handler[1]]);
|
$response = call_user_func([$controller, $handler[1]]);
|
||||||
} catch (Exception $exception) {
|
} catch (Exception $exception) {
|
||||||
$this->dbConnection->rollback();
|
$this->dbConnection->rollback();
|
||||||
|
$this->writeErrorLog($exception);
|
||||||
$this->render500($exception);
|
$this->render500($exception);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -151,4 +153,15 @@ class HttpResponse
|
|||||||
}
|
}
|
||||||
return $url;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user