File tree 2 files changed +17
-5
lines changed
2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change 6
6
* If this is set to "null", the app.debug config value will be used.
7
7
*/
8
8
'enabled ' => env ('QUERY_DETECTOR_ENABLED ' , null ),
9
-
9
+
10
10
/*
11
11
* Threshold level for the N+1 query detection. If a relation query will be
12
12
* executed more then this amount, the detector will notify you about it.
27
27
//]
28
28
],
29
29
30
+ /*
31
+ * Here you can set a specific log channel to write to
32
+ * in case you are trying to isolate queries or have a lot
33
+ * going on in the laravel.log. Defaults to laravel.log though.
34
+ */
35
+ 'log_channel ' => env ('QUERY_DETECTOR_LOG_CHANNEL ' , 'daily ' ),
36
+
30
37
/*
31
38
* Define the output format that you want to use. Multiple classes are supported.
32
39
* Available options are:
Original file line number Diff line number Diff line change @@ -15,22 +15,27 @@ public function boot()
15
15
16
16
public function output (Collection $ detectedQueries , Response $ response )
17
17
{
18
- LaravelLog:: info ('Detected N+1 Query ' );
18
+ $ this -> log ('Detected N+1 Query ' );
19
19
20
20
foreach ($ detectedQueries as $ detectedQuery ) {
21
21
$ logOutput = 'Model: ' .$ detectedQuery ['model ' ] . PHP_EOL ;
22
-
22
+
23
23
$ logOutput .= 'Relation: ' .$ detectedQuery ['relation ' ] . PHP_EOL ;
24
24
25
25
$ logOutput .= 'Num-Called: ' .$ detectedQuery ['count ' ] . PHP_EOL ;
26
-
26
+
27
27
$ logOutput .= 'Call-Stack: ' . PHP_EOL ;
28
28
29
29
foreach ($ detectedQuery ['sources ' ] as $ source ) {
30
30
$ logOutput .= '# ' .$ source ->index .' ' .$ source ->name .': ' .$ source ->line . PHP_EOL ;
31
31
}
32
32
33
- LaravelLog:: info ($ logOutput );
33
+ $ this -> log ($ logOutput );
34
34
}
35
35
}
36
+
37
+ private function log (string $ message )
38
+ {
39
+ LaravelLog::channel (config ('querydetector.log_channel ' ))->info ($ message );
40
+ }
36
41
}
You can’t perform that action at this time.
0 commit comments