Welcome Guest, Not a member yet? Register   Sign In
log_message when db_debug is false
#1

[eluser]Unknown[/eluser]
For production code, I dont want to display database errors to the user via display_error, I want them logged to a file.

So I set:
- error_reporting(0) in index.php
- db_debug = FALSE in config/database.php
- set log_threshold appropriately in config/config.php
- make sure my logs directory is writable

This exposes a bug in DB_driver.php:

I think that code like this:
if ($this->db_debug)
{
log_message('error', 'Invalid query: '.$sql);
return $this->display_error('db_invalid_query');
}
should be changed to:
log_message('error', 'Invalid query: '.$sql);
if ($this->db_debug)
{
return $this->display_error('db_invalid_query');
}

so that database errors will be logged even when db_debug is false.

Many of the display_error instances in DB_driver.php are already written this way, but others (including 2 in the main query function) need this fix so that log_message will work when db_debug is false.




Theme © iAndrew 2016 - Forum software by © MyBB