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

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

Tags: