Skip to content

Instantly share code, notes, and snippets.

@sineld
Forked from kapv89/query-logger.php
Created May 16, 2013 14:28
Show Gist options
  • Select an option

  • Save sineld/5592118 to your computer and use it in GitHub Desktop.

Select an option

Save sineld/5592118 to your computer and use it in GitHub Desktop.
<?php
Event::listen('illuminate.query', function($query, $bindings, $time) {
static $count;
if(App::make('env') === 'local')
{
$logFile = __DIR__.'/storage/logs/queries';
ob_start();
var_dump($bindings, $query);
$str = ob_get_clean();
if($count === null)
{
File::put($logFile, '');
$count = 1;
}
$msg = $count++ . '---------------------------------------'.PHP_EOL;
$msg .= $str.PHP_EOL;
$msg .= '--------------------------------------------------------------'.PHP_EOL.PHP_EOL;
File::append($logFile, $msg);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment