[wp-hackers] WordPress Logging API

Jacob Santos wordpress at santosj.name
Tue Feb 5 06:36:13 GMT 2008

I'm undecided on my own work. It feels dirty, somehow and I'm not sure 
how to improve it. I'm thinking I'm putting too much into the patch and 
should contain just the requirements. 
http://trac.wordpress.org/ticket/5669 is the location of the bug and 
where the code is.

I tested the code and I do like how it works, very well. If I can 
convert parts of the WordPress core over to it, it should produce good 
results with reporting. Indeed, it is also possible to get rid of the 
error_reporting code completely by using the new API. There will be no 
need and will catch (based on PHP.net documentation) notices and warning 
blocked by the damn '@' character. This is both a boon and also an 

I've come to the conclusion that, in my opinion, the display code should 
not be part of the WordPress core and the only function(s) that should 
exist in functions.php are wp_log() and wp_log_error_handler(). I added 
wp_log_exception_handler(), but since WP_Error isn't an exception, it 
would be quite pointless to catch exceptions. It is doubtful, but 
probably only a handful that actually use exceptions in their code. 
However, my plugin does have exceptions (which I should catch anyway, so 
I have to add that to the todo) and it might be worth having a exception 
handler. However, it would require checking for the function existence 
and from the debug.php, it is quite ugly code and doesn't belong in 
functions.php. It should be left to the replacement.

I'm beginning to realize what pishmishy was getting at and the end 
result might end up looking like that person's draft. However, I would 
rather have some more eyes on it, if you will. I can see the increased 
benefit to core developers, plugin authors, and testers now.

I'm thinking have the wp-content/debug.php file used to supplement the 
functionality along with the non-pluggable wp_log(), which doesn't have 
to make use of the functions, the file could easily be moved to a plugin 
also, if WordPress also handled exceptions.

I think the latest addition is just fine. The display code was moved to 
a plugin and since the plugins hook into the shutdown action, the 
function has access to all of the globals and only need to open a file 
once to write all of the errors. I'm thinking this is better. WordPress 
core shouldn't be concern with the display of the functions and if 
WP_DEBUG is not defined, then error_reporting will handle everything as 
it should.

I'm unsure if this will get into 2.5 for plugins, but the work involved 
should at least give a starting point for further discussion for 2.6.


Jacob Santos

http://www.santosj.name - blog
http://funcdoc.wordpress.com - WordPress Documentation Blog/Guide Licensed under GPLv2

Also known as darkdragon and santosj on WP trac.


More information about the wp-hackers mailing list