Skip to content

Instantly share code, notes, and snippets.

@andrija-naglic
Created September 3, 2018 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrija-naglic/dae653a2b0fb7da652fbf19aa37697af to your computer and use it in GitHub Desktop.
Save andrija-naglic/dae653a2b0fb7da652fbf19aa37697af to your computer and use it in GitHub Desktop.
Short WP function that is used to output custom data to debug.log
<?php
function write_log ( $log, $text = "write_log: ", $delete = false ) {
if( $delete ){
unlink( WP_CONTENT_DIR . '/debug.log' );
}
if ( is_array( $log ) || is_object( $log ) ) {
error_log( $text . PHP_EOL . print_r( $log, true ) );
} else {
error_log( $text . PHP_EOL . $log );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment