Skip to content

Instantly share code, notes, and snippets.

@CatEntangler
Created February 26, 2018 03:06
Show Gist options
  • Save CatEntangler/18295a6578c09223c8053011e82db221 to your computer and use it in GitHub Desktop.
Save CatEntangler/18295a6578c09223c8053011e82db221 to your computer and use it in GitHub Desktop.
Log anything to error log with pretty printing
if( ! function_exists('_log') ) {
/**
* @description Takes any message and sends it to the error_log. Due to how php's serialize works (will add binary characters) and that error_log will truncate when it hits a binary character a str_replace is used.
*
* @param $message mixed anything you want to print out
*/
function _log( $message ) {
error_log( str_replace( "\0", "[NULL]", print_r( $message, TRUE ) ) );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment