Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
7 changes: 5 additions & 2 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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
));
}
Expand Down