diff --git a/exception/ErrorHandler.php b/exception/ErrorHandler.php index 57aa8ae..0773a4a 100644 --- a/exception/ErrorHandler.php +++ b/exception/ErrorHandler.php @@ -30,8 +30,11 @@ class ErrorHandler static public function logError($exception) { $error = 0; + $exception_name = ''; if ($exception instanceof ErrorException) { $error = $exception->getSeverity(); + } else { + $exception_name = get_class($exception) . ': '; } switch ($error) { @@ -48,7 +51,7 @@ class ErrorHandler $error = 'Unknown Error'; 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 error_log($message); } diff --git a/tests/app/FrontControllerTest.php b/tests/app/FrontControllerTest.php index 55709a1..654d733 100644 --- a/tests/app/FrontControllerTest.php +++ b/tests/app/FrontControllerTest.php @@ -149,7 +149,7 @@ class FrontControllerTest extends PHPUnit_Framework_TestCase $this->assertContains('Route for "" not found', $result); $this->assertContains('Error404Exception', $result); $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(); $this->assertContains('Action class "userAction" not found.', $result); $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(); $this->assertContains('Layout class "DefaultLayout" not found.', $result); $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); } /** diff --git a/tests/exception/ErrorHandlerTest.php b/tests/exception/ErrorHandlerTest.php index 8740610..47c7990 100644 --- a/tests/exception/ErrorHandlerTest.php +++ b/tests/exception/ErrorHandlerTest.php @@ -97,7 +97,7 @@ class ErrorHandlerTest extends PHPUnit_Framework_TestCase ini_set('error_log', $this->log_file_name); ErrorHandler::logError($ex); $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); ErrorHandler::logError($ex); $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); - } /** @@ -130,7 +129,7 @@ class ErrorHandlerTest extends PHPUnit_Framework_TestCase ini_set('error_log', $this->log_file_name); ErrorHandler::logError($ex); $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); } /**