diff --git a/README.md b/README.md index 74e1752..2a73003 100644 --- a/README.md +++ b/README.md @@ -38,11 +38,16 @@ return [ // Only record queries that are slower than the following time // Unit: milliseconds - 'slower_than' => 0, + 'slower_than' => 0, // Only record queries when the QUERY_LOG_TRIGGER is set in the environment, // or when the trigger HEADER, GET, POST, or COOKIE variable is set. - 'trigger' => env('QUERY_LOG_TRIGGER'), + 'trigger' => env('QUERY_LOG_TRIGGER'), + + // Except record queries + 'except' => [ + // '*_telescope_*', + ], // Log Channel 'channel' => 'stack', diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 118b393..73afcb1 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -33,7 +33,10 @@ public function boot() } $this->app['events']->listen(QueryExecuted::class, function (QueryExecuted $query) { - if ($query->time < $this->app['config']->get('logging.query.slower_than', 0)) { + if ( + $query->time < $this->app['config']->get('logging.query.slower_than', 0) + || str($query->sql)->is($this->app['config']->get('logging.query.except', [])) + ) { return; } @@ -46,7 +49,7 @@ public function boot() if (count($bindings) > 0) { $realSql = vsprintf($sqlWithPlaceholders, array_map( - static fn($binding) => $binding === null ? 'NULL' : $pdo->quote($binding), + static fn ($binding) => $binding === null ? 'NULL' : $pdo->quote($binding), $bindings )); }