Separate function ErrorHandler::logError() and tests
This commit is contained in:
@ -27,6 +27,42 @@ class ErrorHandler
|
||||
return true;
|
||||
}
|
||||
|
||||
static public function logError($exception)
|
||||
{
|
||||
$error = 0;
|
||||
if ($exception instanceof ErrorException) {
|
||||
$error = $exception->getSeverity();
|
||||
}
|
||||
|
||||
switch ($error) {
|
||||
case E_NOTICE:
|
||||
$error = 'Notice';
|
||||
break;
|
||||
case E_WARNING:
|
||||
$error = 'Warning';
|
||||
break;
|
||||
case E_ERROR:
|
||||
$error = 'Fatal Error';
|
||||
break;
|
||||
default:
|
||||
$error = 'Unknown Error';
|
||||
break;
|
||||
}
|
||||
$message = 'PHP ' . $error . ': ' . $exception->getMessage() . ' in ' . $exception->getFile() . ':' . $exception->getLine() . ' \nStack trace:\n' . $exception->getTraceAsString() . self::getHTTPEErrorConditions();
|
||||
// PHP Fatal error: Uncaught exception 'LogicException' in /www/test.tfs/face/htdocs/index.php:11\nStack trace:\n#0 {main}\n thrown in /www/test.tfs/face/htdocs/index.php on line 11, referer: http://test.tfs.manekeno.netmonsters.ru/news/create
|
||||
error_log($message);
|
||||
}
|
||||
|
||||
static public function getHTTPEErrorConditions()
|
||||
{
|
||||
$text = null;
|
||||
if (!is_null(Env::Server('REQUEST_METHOD')) && !is_null(Env::Server('REQUEST_URI'))) {
|
||||
$text = ', URL: ' . Env::Server('REQUEST_METHOD') . ' ' . Env::Server('REQUEST_URI');
|
||||
$text .= ', referrer: ' . Env::Server('HTTP_REFERER');
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
|
||||
static protected function getSource($file, $hiline)
|
||||
{
|
||||
$code = array();
|
||||
|
Reference in New Issue
Block a user