$lines = debug_backtrace();

$indent = '';
foreach ($lines as $line)
{
   log($indent . $line['line'] . ': ' . $line['function']); // your own log function
   $indent .= '  ';
}