Skip to content

Instantly share code, notes, and snippets.

@stefanheimes
Created March 13, 2014 22:58
Show Gist options
  • Save stefanheimes/9538959 to your computer and use it in GitHub Desktop.
Save stefanheimes/9538959 to your computer and use it in GitHub Desktop.
Trace for php
<?php
function log_place()
{
$e = new \Exception();
$trace = $e->getTrace();
$file = @$trace[0]['file'];
$line = @$trace[0]['line'];
$class = @$trace[1]['class'];
$function = @$trace[1]['function'];
$method = ($class ? $class . '::' : '') . $function;
file_put_contents(
TL_ROOT . '/debug-trace.log',
sprintf('%s %d %s' .PHP_EOL, $file, $line, $method),
FILE_APPEND
);
}
register_tick_function('log_place');
declare(ticks=1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment