Logging debug arbitrary information


/ Published in: PHP
Save to your folder(s)

In certain cases, it is useful to display additional information in a journal that does not report an error, but simply helps in writing your own code. For this PHP provides the function error_log ().
This function does not provide formatting, so you can create your own wrapper over error_log, formatting objects and variables that are written to the log using the print_r () function


Copy this code and paste it in your HTML
  1. <?php
  2. /*
  3. Plugin Name: Log Error
  4. */
  5. if ( ! function_exists('write_log')) {
  6. function write_log ( $log ) {
  7. if ( is_array( $log ) || is_object( $log ) ) {
  8. error_log( print_r( $log, true ) );
  9. } else {
  10. error_log( $log );
  11. }
  12. }
  13. }
  14.  
  15.  
  16. ?>

URL: http://delaemsait.info/primenenie-zhurnala-otladki-v-wordpress/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.