Skip to content

Commit 0ae9a6b

Browse files
authored
Merge pull request #31 from plakhin/patch-1
Add Clockwork output
2 parents ae2a4f9 + 591ad60 commit 0ae9a6b

File tree

3 files changed

+43
-20
lines changed

3 files changed

+43
-20
lines changed

README.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,31 +66,36 @@ return [
6666
],
6767

6868
/*
69-
* Define the output format that you want to use. Multiple classes are supported
69+
* Define the output format that you want to use. Multiple classes are supported.
7070
* Available options are:
7171
*
7272
* Alert:
7373
* Displays an alert on the website
7474
* \BeyondCode\QueryDetector\Outputs\Alert::class
7575
*
76-
* Debugbar: (make sure you have the barryvdh/laravel-debugbar package installed)
77-
* Writes the N+1 queries into a custom messages collector of Debugbar
78-
* \BeyondCode\QueryDetector\Outputs\Debugbar::class
79-
*
80-
* Log:
81-
* Writes the N+1 queries into the Laravel.log file
82-
* \BeyondCode\QueryDetector\Outputs\Log::class
83-
*
8476
* Console:
8577
* Writes the N+1 queries into your browsers console log
8678
* \BeyondCode\QueryDetector\Outputs\Console::class
8779
*
80+
* Clockwork: (make sure you have the itsgoingd/clockwork package installed)
81+
* Writes the N+1 queries warnings to Clockwork log
82+
* \BeyondCode\QueryDetector\Outputs\Clockwork::class
83+
*
84+
* Debugbar: (make sure you have the barryvdh/laravel-debugbar package installed)
85+
* Writes the N+1 queries into a custom messages collector of Debugbar
86+
* \BeyondCode\QueryDetector\Outputs\Debugbar::class
87+
*
8888
* JSON:
8989
* Writes the N+1 queries into the response body of your JSON responses
9090
* \BeyondCode\QueryDetector\Outputs\Json::class
91+
*
92+
* Log:
93+
* Writes the N+1 queries into the Laravel.log file
94+
* \BeyondCode\QueryDetector\Outputs\Log::class
9195
*/
9296
'output' => [
93-
\BeyondCode\QueryDetector\Outputs\Alert::class
97+
\BeyondCode\QueryDetector\Outputs\Log::class,
98+
\BeyondCode\QueryDetector\Outputs\Alert::class,
9499
]
95100

96101
];

config/config.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,35 @@
2222
],
2323

2424
/*
25-
* Define the output formats that you want to use.
25+
* Define the output format that you want to use. Multiple classes are supported.
2626
* Available options are:
2727
*
2828
* Alert:
2929
* Displays an alert on the website
3030
* \BeyondCode\QueryDetector\Outputs\Alert::class
3131
*
32-
* Debugbar: (make sure you have the barryvdh/laravel-debugbar package installed)
33-
* Writes the N+1 queries into a custom messages collector of Debugbar
34-
* \BeyondCode\QueryDetector\Outputs\Debugbar::class
35-
*
36-
* Log:
37-
* Writes the N+1 queries into the Laravel.log file
38-
* \BeyondCode\QueryDetector\Outputs\Log::class
39-
*
4032
* Console:
4133
* Writes the N+1 queries into your browsers console log
4234
* \BeyondCode\QueryDetector\Outputs\Console::class
4335
*
36+
* Clockwork: (make sure you have the itsgoingd/clockwork package installed)
37+
* Writes the N+1 queries warnings to Clockwork log
38+
* \BeyondCode\QueryDetector\Outputs\Clockwork::class
39+
*
40+
* Debugbar: (make sure you have the barryvdh/laravel-debugbar package installed)
41+
* Writes the N+1 queries into a custom messages collector of Debugbar
42+
* \BeyondCode\QueryDetector\Outputs\Debugbar::class
43+
*
4444
* JSON:
4545
* Writes the N+1 queries into the response body of your JSON responses
4646
* \BeyondCode\QueryDetector\Outputs\Json::class
47+
*
48+
* Log:
49+
* Writes the N+1 queries into the Laravel.log file
50+
* \BeyondCode\QueryDetector\Outputs\Log::class
4751
*/
4852
'output' => [
49-
\BeyondCode\QueryDetector\Outputs\Log::class,
5053
\BeyondCode\QueryDetector\Outputs\Alert::class,
54+
\BeyondCode\QueryDetector\Outputs\Log::class,
5155
]
5256
];

src/Outputs/Clockwork.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace BeyondCode\QueryDetector\Outputs;
4+
5+
use Illuminate\Support\Collection;
6+
use Symfony\Component\HttpFoundation\Response;
7+
8+
class Clockwork implements Output
9+
{
10+
public function output(Collection $detectedQueries, Response $response)
11+
{
12+
clock()->warning("{$detectedQueries->count()} N+1 queries detected:", $detectedQueries->toArray());
13+
}
14+
}

0 commit comments

Comments
 (0)