Added exception name to log
This commit is contained in:
@ -30,8 +30,11 @@ class ErrorHandler
|
|||||||
static public function logError($exception)
|
static public function logError($exception)
|
||||||
{
|
{
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
$exception_name = '';
|
||||||
if ($exception instanceof ErrorException) {
|
if ($exception instanceof ErrorException) {
|
||||||
$error = $exception->getSeverity();
|
$error = $exception->getSeverity();
|
||||||
|
} else {
|
||||||
|
$exception_name = get_class($exception) . ': ';
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($error) {
|
switch ($error) {
|
||||||
@ -48,7 +51,7 @@ class ErrorHandler
|
|||||||
$error = 'Unknown Error';
|
$error = 'Unknown Error';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$message = 'PHP ' . $error . ': ' . $exception->getMessage() . ' in ' . $exception->getFile() . ':' . $exception->getLine() . ' \nStack trace:\n' . $exception->getTraceAsString() . self::getHTTPErrorConditions();
|
$message = 'PHP ' . $error . ': ' . $exception_name . $exception->getMessage() . ' in ' . $exception->getFile() . ':' . $exception->getLine() . ' \nStack trace:\n' . $exception->getTraceAsString() . self::getHTTPErrorConditions();
|
||||||
// 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
|
// 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);
|
error_log($message);
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ class FrontControllerTest extends PHPUnit_Framework_TestCase
|
|||||||
$this->assertContains('Route for "" not found', $result);
|
$this->assertContains('Route for "" not found', $result);
|
||||||
$this->assertContains('Error404Exception', $result);
|
$this->assertContains('Error404Exception', $result);
|
||||||
$error = file_get_contents($this->log_file_name);
|
$error = file_get_contents($this->log_file_name);
|
||||||
$this->assertContains('PHP Unknown Error: Route for "" not found', $error);
|
$this->assertContains('PHP Unknown Error: Error404Exception: Route for "" not found in ', $error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -166,7 +166,7 @@ class FrontControllerTest extends PHPUnit_Framework_TestCase
|
|||||||
$result = $controller->execute();
|
$result = $controller->execute();
|
||||||
$this->assertContains('Action class "userAction" not found.', $result);
|
$this->assertContains('Action class "userAction" not found.', $result);
|
||||||
$error = file_get_contents($this->log_file_name);
|
$error = file_get_contents($this->log_file_name);
|
||||||
$this->assertContains('PHP Unknown Error: Action class "userAction" not found.', $error);
|
$this->assertContains('PHP Unknown Error: GeneralException: Action class "userAction" not found. in ', $error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -184,7 +184,7 @@ class FrontControllerTest extends PHPUnit_Framework_TestCase
|
|||||||
$result = $controller->execute();
|
$result = $controller->execute();
|
||||||
$this->assertContains('Layout class "DefaultLayout" not found.', $result);
|
$this->assertContains('Layout class "DefaultLayout" not found.', $result);
|
||||||
$error = file_get_contents($this->log_file_name);
|
$error = file_get_contents($this->log_file_name);
|
||||||
$this->assertContains('PHP Unknown Error: Layout class "DefaultLayout" not found.', $error);
|
$this->assertContains('PHP Unknown Error: GeneralException: Layout class "DefaultLayout" not found. in ', $error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,7 +97,7 @@ class ErrorHandlerTest extends PHPUnit_Framework_TestCase
|
|||||||
ini_set('error_log', $this->log_file_name);
|
ini_set('error_log', $this->log_file_name);
|
||||||
ErrorHandler::logError($ex);
|
ErrorHandler::logError($ex);
|
||||||
$log = file_get_contents($this->log_file_name);
|
$log = file_get_contents($this->log_file_name);
|
||||||
$this->assertContains('PHP Unknown Error: message in ', $log);
|
$this->assertContains('PHP Unknown Error: Exception: message in ', $log);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -116,9 +116,8 @@ class ErrorHandlerTest extends PHPUnit_Framework_TestCase
|
|||||||
ini_set('error_log', $this->log_file_name);
|
ini_set('error_log', $this->log_file_name);
|
||||||
ErrorHandler::logError($ex);
|
ErrorHandler::logError($ex);
|
||||||
$log = file_get_contents($this->log_file_name);
|
$log = file_get_contents($this->log_file_name);
|
||||||
$this->assertContains('PHP Unknown Error: message in ', $log);
|
$this->assertContains('PHP Unknown Error: Exception: message in ', $log);
|
||||||
$this->assertContains('URL: GET /somelongurl, referrer: http://referrer/url', $log);
|
$this->assertContains('URL: GET /somelongurl, referrer: http://referrer/url', $log);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -130,7 +129,7 @@ class ErrorHandlerTest extends PHPUnit_Framework_TestCase
|
|||||||
ini_set('error_log', $this->log_file_name);
|
ini_set('error_log', $this->log_file_name);
|
||||||
ErrorHandler::logError($ex);
|
ErrorHandler::logError($ex);
|
||||||
$log = file_get_contents($this->log_file_name);
|
$log = file_get_contents($this->log_file_name);
|
||||||
$this->assertContains('PHP Unknown Error: Logic in ', $log);
|
$this->assertContains('PHP Unknown Error: LogicException: Logic in ', $log);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user