Commonly, while utilizing application, we run over blunders. It is extremely irritating for the clients if the mistakes are not taken care of appropriately. CodeIgniter gives a simple blunder taking care of system.
You might want the messages to be shown, when the application is in creating mode instead of underway mode as the mistake messages can be fathomed effectively at the creating stage.
The earth of your application can be changed, by changing the line given beneath from index.php record. This can be set to anything other than regularly there are three qualities (advancement, test, creation) utilized for this reason.
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'improvement');
Diverse condition will require various degrees of blunder revealing. Of course, advancement mode will show blunders and testing and live mode will shroud them. CodeIgniter gives three capacities as appeared underneath to deal with mistakes.
- show_error() work shows blunders in HTML design at the highest point of the screen.
Syntax |
show_error($message, $status_code, $heading = 'An Error Was Encountered') |
Parameters |
|
Return Type |
mixed |
-
show_404()function displays error if you are trying to access a page which does not exist.
Syntax |
show_404($page = '', $log_error = TRUE) |
Parameters |
|
Return Type |
void |
-
log_message()function is used to write log messages. This is useful when you want to write custom messages.
Syntax |
log_message($level, $message, $php_error = FALSE) |
Parameters |
|
Return Type |
void |
Logging can be enabled inapplication/config/config.phpfile. Given below is the screenshot of config.php file, where you can set threshold value.
/*
|--------------------------------------------------------------------------------
| Error Logging Threshold
|--------------------------------------------------------------------------------
| You can enable error logging by setting a threshold over zero. The
| threshold determines what gets logged. Threshold options are:
|
| 0 = Disable logging, Error logging TURNED OFF
| 1 = Error Message (including PHP errors)
| 2 = Debug Message
| 3 = Informational Messages
| 4 = All Messages
|
| You can also pass an array with threshold levels to show individual error types
|
| array(2) = Debug Message, without Error Messages
| For a live site you'll usually only enable Errors (1) to be logged otherwise
| your log files will fill up very fast.
|
*/
$config['log_threshold'] = 0;
You can discover the log messages in application/log/. Ensure that this catalog is writable before you empower log documents.
Different formats for mistake messages can be found in application/sees/blunders/cli or application/sees/blunders/html.
