File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change 66 * If this is set to "null", the app.debug config value will be used.
77 */
88 'enabled ' => env ('QUERY_DETECTOR_ENABLED ' , null ),
9-
9+
1010 /*
1111 * Threshold level for the N+1 query detection. If a relation query will be
1212 * executed more then this amount, the detector will notify you about it.
2727 //]
2828 ],
2929
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+
3037 /*
3138 * Define the output format that you want to use. Multiple classes are supported.
3239 * Available options are:
Original file line number Diff line number Diff line change @@ -15,22 +15,27 @@ public function boot()
1515
1616 public function output (Collection $ detectedQueries , Response $ response )
1717 {
18- LaravelLog:: info ('Detected N+1 Query ' );
18+ $ this -> log ('Detected N+1 Query ' );
1919
2020 foreach ($ detectedQueries as $ detectedQuery ) {
2121 $ logOutput = 'Model: ' .$ detectedQuery ['model ' ] . PHP_EOL ;
22-
22+
2323 $ logOutput .= 'Relation: ' .$ detectedQuery ['relation ' ] . PHP_EOL ;
2424
2525 $ logOutput .= 'Num-Called: ' .$ detectedQuery ['count ' ] . PHP_EOL ;
26-
26+
2727 $ logOutput .= 'Call-Stack: ' . PHP_EOL ;
2828
2929 foreach ($ detectedQuery ['sources ' ] as $ source ) {
3030 $ logOutput .= '# ' .$ source ->index .' ' .$ source ->name .': ' .$ source ->line . PHP_EOL ;
3131 }
3232
33- LaravelLog:: info ($ logOutput );
33+ $ this -> log ($ logOutput );
3434 }
3535 }
36+
37+ private function log (string $ message )
38+ {
39+ LaravelLog::channel (config ('querydetector.log_channel ' ))->info ($ message );
40+ }
3641}
You can’t perform that action at this time.
0 commit comments