Linux 软件免费装

RHJ4 Diagnostics

开发者 Bob Jones
更新时间 2014年10月9日 23:32
捐献地址: 去捐款
PHP版本: 3.0.1 及以上
WordPress版本: 3.9
版权: GPLv2 or later
版权网址: 版权信息

标签

debugging diagnostics

下载

详情介绍:

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.

安装:

  1. Upload the contents of the zip file to the /wp-content/plugins/ directory
  2. Activate the plugin through the 'Plugins' menu in WordPress
  3. Enable plugin using shortcodes or explicitly in your code

升级注意事项:

= 1.0 = Initial version

常见问题:

Why do I need this plugin?

There are only three commonly used methods to debug code:

  1. Iteratively alter the code until you get the desired effect. This is useful for fine-tuning screen layouts, but not for code bugs.
  2. Use diagnostic trace statements to capture critical flow information.
  3. Use a debugger with breakpoints so you can stop and examine code and variables.
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?

  1. The error log file's location is defined in php.ini and, depending on your configuration, may not be visible to you.
  2. You can easily enable and disable logging at various places in your code.
  3. Diagnostic statements can be written into a variety of files or even databases.
  4. You can add the shortcode [rhj4_diagnostics show=true] to any page and see the entire contents of the current logfile.
  5. The shortcode [rhj4_diagnostics clear=true] will delete the logfile.

Can I enable and disable logging without having to delete all my trace statements?

RHJ4Diagnostics::instance('enabled'=>true|false);

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);

更新日志:

1.2 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. 1.1 Added substantial shortcode support. Added threshold option.