views:

18

answers:

1

I have some problem with error logging in Kohana v2.3.4.

In the index.php I have kept the default settings:
error_reporting(E_ALL);
ini_set('display_errors', TRUE);

In config.php I have set
$config['log_threshold'] = 3;
$config['display_errors'] = FALSE;

The problem is kohana is not handling php syntax errors.
Instead the default php error message gets displayed on screen.
To stop error messages from getting displayed in production I have to set

error_reporting(0);

But this will suppress other errors(Ex: missing function arguments or undefined array index) from getting logged by kohana.

In short
1. I want above mentioned errors(missing function arguments or undefined array index) to be logged by kohana.
2. I don't want php syntax errors to be displayed on screen.

Is it possible with kohana 2.3.4?

A: 

You need to overload the shutdown handler and check for an E_PARSE error. You can see an example of this code in the Kohana 3 Shutdown handler. All you need to do is get the error details from error_get_last() and work from there.

The Kohana 2 Shutdown handler does no such checking.

Note: Since it's called the shutdown_handler you have to output or log the error. There's no chance your application will be carrying on.

Hoped that helped.

The Pixel Developer