Skip to content

Instantly share code, notes, and snippets.

@noeldiaz
Forked from kapv89/query-logger.php
Created May 16, 2013 15:21
Show Gist options
  • Save noeldiaz/5592516 to your computer and use it in GitHub Desktop.
Save noeldiaz/5592516 to your computer and use it in GitHub Desktop.
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