Skip to content

Instantly share code, notes, and snippets.

@karlazz
Created December 8, 2016 00:17
Show Gist options
  • Save karlazz/aa6ddc582a35c74b95a290f899ba8304 to your computer and use it in GitHub Desktop.
Save karlazz/aa6ddc582a35c74b95a290f899ba8304 to your computer and use it in GitHub Desktop.
//* add a trace file
$upload_dir = wp_upload_dir();
define('TRACEFILE', $upload_dir['basedir'] . '/trace.log');
function trace($log) {
$prefix = current_time( 'mysql' ) . ": " ;
$suffix = "\n" ;
if ( is_array( $log ) || is_object( $log ) ) {
error_log( $prefix, 3, TRACEFILE);
error_log( print_r( $log, true ) , 3, TRACEFILE );
error_log( $suffix, 3, TRACEFILE ) ;
}
else {
error_log( $prefix . $log . $suffix, 3, TRACEFILE );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment