If it is at all possible for you to get this information in any way, I'd recommend turning on the slow query log.
Else, you are stuck with PHP as far as I know. However, if you are using a class to handle all queries, setting up a logging function in php is quite easy. No need to go over all the code. You just change what happens in a call to DB::query();
If not, I'd create such a class and then go over all code and make sure that all queries pass through the new class. And it also has other benefits. You will only need to deal with error logging in one single place. If you're not using mysqli today, now's a good time to switch (and to using prepared statements). And if that's not an option presently, when you do have this possibility, you change the code once, not everywhere.