Skip to content

Instantly share code, notes, and snippets.

@vedovelli
Created September 23, 2016 18:40
Show Gist options
  • Save vedovelli/c0bfe1676938b0a76e358470e9023791 to your computer and use it in GitHub Desktop.
Save vedovelli/c0bfe1676938b0a76e358470e9023791 to your computer and use it in GitHub Desktop.
\DB::listen(function ($query) {
$fullQuery = vsprintf(str_replace(array('%', '?'), array('%%', '%s'), $query->sql), $query->bindings);
$logString = "Connection: {$query->connectionName}
Execution time: {$query->time}ms
Query: ${fullQuery}
---------------------" . PHP_EOL;
\Storage::append('logs/queries.log', $logString);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment