Skip to content

Instantly share code, notes, and snippets.

@thenbrent
Last active September 14, 2016 15:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thenbrent/2396367 to your computer and use it in GitHub Desktop.
Save thenbrent/2396367 to your computer and use it in GitHub Desktop.
PHP Stacktrace to `error_log()` using `debug_backtrace()`.
<?php
foreach ( debug_backtrace() as $key => $value ) {
$function = @$value['function'];
if( isset( $value['class'] ) )
$function = $value['class'] . '::' . $function;
//error_log( "** " . $key . ". " . $function . "( " . str_replace( array("\n","\t",' ','(',')'), '', print_r( $value['args'], true ) ) . " )" );
//error_log( "** " . $key . ". " . $function . "( " . implode( ', ', @$value['args'] ) . " )" );
error_log( "** " . $key . ". " . $function . "( " . serialize( @$value['args'] ) . " )" );
error_log( "** FILE: " . @$value['file'] . ":" . @$value['line'] );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment