You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: log-and-debug.md
+30Lines changed: 30 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,7 @@
9
9
-[Log with context](#log-with-context)
10
10
-[Quickly output an Eloquent query in its SQL form](#quickly-output-an-eloquent-query-in-its-sql-form)
11
11
-[Log all the database queries during development](#log-all-the-database-queries-during-development)
12
+
-[Discover all events fired in one request](#discover-all-events-fired-in-one-request)
12
13
13
14
### Logging with parameters
14
15
@@ -113,3 +114,32 @@ public function boot()
113
114
114
115
Tip given by [@mmartin_joo](https://twitter.com/mmartin_joo/status/1473262634405449730)
115
116
117
+
### Discover all events fired in one request
118
+
119
+
If you want to implement a new listener to a specific event but you don't know its name, you can log all events fired during the request.
120
+
121
+
You can use the `\Illuminate\Support\Facades\Event::listen()` method on `boot()` method of `app/Providers/EventServiceProvider.php` to catch all events fired.
122
+
123
+
**Important:** If you use the `Log` facade within this event listener then you will need to exclude events named `Illuminate\Log\Events\MessageLogged` to avoid an infinite loop.
0 commit comments