Joshua David Nelson

Bullshit Free WordPress Development

  • Services
  • Code
  • About
  • Contact

Log Errors in WordPress

Handy for development, just call it up jdn_log_me( 'An issue' );

<?php
/**
* Log any errors for debugging.
*
* @global WP_DEBUG
* @uses error_log
* @var string|array $message the error message (a string or array)
*/
if( !function_exists( 'jdn_log_me' ) ) {
function jdn_log_me( $message ) {
if ( WP_DEBUG === true ) {
if ( is_array( $message ) || is_object( $message ) ) {
error_log( 'Custom Plugin Error: ' . print_r( $message, true ) );
} else {
error_log( 'Custom Plugin Error: ' . $message );
}
}
}
}
view raw wordpress-debug-logger.php hosted with ❤ by GitHub

Source: https://gist.github.com/joshuadavidnelson/b315bcd407b12cdb052f

Tags: debug

Previous Code:
Add WooCommerce Product Description Below Product
Back to the Code Snippets
Next Code:
Add Shortcode Support to Custom Field Output
  • Twitter
  • RSS Feed URL

About Me

I'm a WordPress Engineer. I build sleek, custom websites with WordPress and Genesis.

See my services and my recent work.

Contact me to get your project started.

Gravity Forms Plugin for WordPress Fastest WordPress Hosting

Recent Posts

  • Using Font Awesome Icons for WooCommerce Grid / List Toggle
  • Disable Blog: WordPress Gone Blog-less
  • Category (Taxonomy) Dropdown Filtered By Post Type
  • Weather in WordPress with Dark Sky
  • Fixing Your Deprecated Widget Constructors in WordPress 4.3
  • Twitter
  • RSS Feed URL
  • Code Snippets
  • My Plugins
  • Make a Payment

© Joshua David Nelson | Hand-Forged | WordPress + Genesis | Terms of Service | Legal | Contact