Skip to content

Instantly share code, notes, and snippets.

@gabrielgilini
Created May 18, 2011 18:05
Show Gist options
  • Select an option

  • Save gabrielgilini/979136 to your computer and use it in GitHub Desktop.

Select an option

Save gabrielgilini/979136 to your computer and use it in GitHub Desktop.
PHP debug to file
<?php
function debug()
{
$args = func_get_args();
ob_start();
$dbt = reset(debug_backtrace(false));
echo date('[d/m/Y H:i:s] ');
echo end(explode('/', $dbt['file'])) . ':' . $dbt['line'] . "\n";
foreach($args as &$arg)
{
var_dump($arg);
echo "\n";
}
echo "\n";
$content = ob_get_contents();
ob_end_clean();
file_put_contents('/tmp/debug.log', $content, FILE_APPEND);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment