User tests: Successful: Unsuccessful:
As a followup to the "Handle DB errors" by @alikon. As requested by @wilsonge
I just added logging to the catches where they were missing.
And I changed one place where the error message still was shown to use the new way of showing a generic message and logging the error.
Should be simple to review.
Milestone |
Added: |
Looks like you are right (as always), but unfortunately it doesn't seem to log anything. Looks like the logger for that category databasequery
isn't specified and thus nothing is written in any logfile.
Or am I to stupid to get that log?
I think you need to enable that in the debug plugin
If I add
JLog::addLogger(
array(
'text_file' => 'databasequery.errors.php'
),
JLog::ALL,
array('databasequery')
);
before
// If an error occurred handle it.
if (!$this->cursor)
it works.
So I guess that logger needs to be defined first somewhere.
Found why it doesn't work.
The plugin explicitely excludes that category from the "log almost everything" logger:
https://github.com/joomla/joomla-cms/blob/staging/plugins/system/debug/debug.php#L104
Anyone knows why?
So we either add a new option to the plugin or just remove that exclusion?
I think @nikosdion excluded it by accident because he thought it would be the category for the actual queries (the other option to log all queries to a file), while it is in fact only for the query errors.
If your logger is set to handle messages of priority JLog::DEBUG
then that category will also log every executed query.
Well, more specifically, a combination of the database driver being in debug mode and a logger set to catch those messages - https://github.com/joomla/joomla-cms/blob/3.4.1/libraries/joomla/database/driver/mysqli.php#L539-L556
Ah I see.
If we remove the category from the exlude, then it would show only the errors while global debug is off, but log all queries if debug is turned on. Not ideal either indeed.
That's why I removed the query logging. If you're running a site in debug mode (typical when developing) you create a supermassive log which has some very undesired consequences.
yeah, makes sense.
I'm thinking if we could create a new logging category for database query errors (databasequeryerrors
) which are included in the "log everything". Because chances are high you want to see those but don't want to see all the other queries.
Yes we could, but it does break b/c with existing third party database drivers. It's not just the custom db drivers for people who want to set up master-slave in MySQL but also the custom db drivers in 3PD extensions (e.g. site translation software). Are we allowed to do that in J! 3.5?
Labels |
Added:
?
|
Category | ⇒ | Modules |
Status | New | ⇒ | Pending |
The custom drivers would behave as today. Meaning database errors would only be logged if they have debug enabled and queries logged.
Our own drivers would instead log the errors with debug either on or off as long as "log almost everything" enabled.
It shouldn't break anything.
I'll try to do a PR tomorrow so we have something to discuss
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2015-06-17 11:45:12 |
Closed_By | ⇒ | Bakual |
Milestone |
Removed: |
IMO this is unnecessary. Every database driver has error handling similar to that of MySQLi which already logs errors.