File tree 1 file changed +7
-6
lines changed
1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change 11
11
12
12
class QueryLoggerServiceProvider extends ServiceProvider
13
13
{
14
+ public const MYSQL = 'mysql ' ;
15
+ public const SQLITE = 'sqlite ' ;
16
+ public const MONGODB = 'mongodb ' ;
17
+
14
18
/**
15
19
* Bootstrap services.
16
20
*
@@ -38,19 +42,16 @@ public function boot(Request $request)
38
42
*/
39
43
protected function listenQueryLogging (LogManager $ logger )
40
44
{
41
- // Enable query logging for all connection
42
- foreach (array_keys (config ('database.connections ' )) as $ connection ) {
43
- app ('db ' )->connection ($ connection )->enableQueryLog ();
44
- }
45
+ app ('db ' )->connection ()->enableQueryLog ();
45
46
46
47
app ('db ' )->listen (function (QueryExecuted $ query ) use ($ logger ) {
47
48
$ driver = $ query ->connection ->getDriverName ();
48
49
49
- if (in_array ($ driver , [' mysql ' , ' sqlite ' ])) {
50
+ if (in_array ($ driver , [static :: SQLITE , static :: MYSQL ])) {
50
51
$ this ->writeMySqlLog ($ query , $ logger );
51
52
}
52
53
53
- if ($ driver === ' mongodb ' ) {
54
+ if ($ driver === static :: MONGODB ) {
54
55
$ this ->writeMongoDbLog ($ query , $ logger );
55
56
}
56
57
});
You can’t perform that action at this time.
0 commit comments