Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where is the best place to automatically/globally log all queries? #44

Open
mikepsinn opened this issue Dec 6, 2018 · 0 comments
Open

Comments

@mikepsinn
Copy link
Contributor

mikepsinn commented Dec 6, 2018

I've tried doing it in a listener in my AppServiceProvider like:

class AppServiceProvider extends ServiceProvider
{
    public function boot(){
        $config = $this->app['config']['tracy'];
        $enabled = Arr::get($config, 'enabled', true) === true;
        if ($enabled === true) {
            /** @var QueryExecuted $query */
            DB::listen(function ($query) {
                $tracy = Tracy::instance();
                $databasePanel = $tracy->getPanel('database');
                /** @var DatabasePanel $databasePanel */
                $databasePanel->logQuery($query->sql, $query->bindings, $query->time);
            });
        }
    }
}

Unfortunately, your super neat findSource function just points me back to my index.php if I do this. Thank you so much! :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant