Posted By

cerxx on 10/18/18


Tagged

debug wordpress tools


Versions (?)

Logging debug arbitrary information


 / Published in: PHP
 

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

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 errorlog (). This function does not provide formatting, so you can create your own wrapper over errorlog, formatting objects and variables that are written to the log using the print_r () function

  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. ?>

Report this snippet  

You need to login to post a comment.