RHJ4 Diagnostics supports program debugging by making it simple to write tracing information into several log files.
|Author:||Bob Jones (profile at wordpress.org)|
|WordPress version required:||3.0.1|
|WordPress version tested:||3.9.2|
|Added to WordPress repository:||20-09-2014|
Warning! This plugin has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.
Click to start download
RHJ4 Diagnostics captures diagnostic messages written in PHP and conditionally directs them to various different logging functions. The plugin can be enabled or disabled during page execution, and it can intercept and handle various classes of PHP errors, e.g. E_ERROR & ~E_NOTICE. The documentation includes numerous usage examples.
Diagnostics works closely with RHJ4 Notifications. Each uses functionality in the other plugin.
Why do I need this plugin?
There are only three commonly used methods to debug code:
Iteratively alter the code until you get the desired effect.
This is useful for fine-tuning screen layouts, but not for code bugs.
Use diagnostic trace statements to capture critical flow information.
Use a debugger with breakpoints so you can stop and examine code and
This plugin makes it simple to write diagnostic information into files on the
server and onto the browser’s console log. Diagnostics on the server can be
written to multiple files simultaneously. PHP error diagnostics can be included
or excluded, and diagnostics can be enabled at specific points in your code
and disabled elsewhere.
What makes this plugin better than simply invoking error_log?
- The error log file’s location is defined in php.ini and, depending on your configuration, may not be visible to you.
- You can easily enable and disable logging at various places in your code.
- Diagnostic statements can be written into a variety of files or even databases.
- You can add the shortcode [rhj4_diagnostics show=true] to any page and see the entire contents of the current logfile.
- The shortcode [rhj4_diagnostics clear=true] will delete the logfile.
Can I enable and disable logging without having to delete all my trace statements?
Can I selectively enable or disable PHP error messages?
$diags->option(array (‘level’ => E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_STRICT);
Will it capture All PHP diagnostics except NOTICE and STRICT messages?
$diags->option(array (‘level’ => 0);
Will it disable capture of PHP diagnostics?
Can I label various messages so I can tell where they came from?
$diags = RHJ4Diagnostics::instance();
$diags->diagnostic(‘Message # 1’, ‘FUNCTION A: ‘);
$diags->diagnostic(‘Message # 2’, ‘FUNCTION B: ‘);
$diags->diagnostic(‘Message # 3’, ‘FUNCTION C: ‘);
Can I write some output into various different log files?
$diags->diagnostic(‘Message text’, array(‘output’=> array(
‘function’ => ‘my_diagnostic_test_output’, ‘logfile’ => ‘demo.log’)));
Can I selectively enable some diagnostic messages and disable others?
Yes. The “threshold” option determines which messages will be displayed.
If the current threshold value is 10 and the message’s threshold value is greater than 10, the message will not be logged. If the message threshold is 10 or less, it will be logged.
$diags = RHJ4Diagnostics::instance(); $diags->options(array('enabled' => true, 'threshold' => 6); $diags->diagnostic('This message will not be logged',array('threshold'=>7)); $diags->diagnostic('This message will be logged',array('threshold'=>5));
Can my settings be remembered across pages?
Yes. On the first page establish your settings like this:
$diags = RHJ4Diagnostics::instance(); $diags->set(array('enabled' => true, 'threshold' => 6);
Enhanced demo considerably.
Added jQuery support for save, clear and show functions. It can now save a diagnostic generated in jQuery or PHP.
Added rhj4_diagnostics_save, rhj4_diagnostics_show and rhj4_diagnostics_clear AJAX functions to support jQuery calls.
Added substantial shortcode support.
Added threshold option.