Skip to content

Instantly share code, notes, and snippets.

@vinaydotblog
Created June 5, 2017 10:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinaydotblog/5809ca15c7873eab6c2b2b6782473537 to your computer and use it in GitHub Desktop.
Save vinaydotblog/5809ca15c7873eab6c2b2b6782473537 to your computer and use it in GitHub Desktop.
Clean query log for laravel
<?php
DB::listen(function ($sql) {
$log = vsprintf('[SQL] - ' . str_replace('?', '"%s"', $sql->sql), $sql->bindings);
if( App::runningInConsole() ) {
print($log);
} else {
\Log::info($log);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment