File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -245,6 +245,12 @@ public function listen(Closure $callback)
245245 */
246246 protected function fireLogEvent ($ level , $ message , array $ context = [])
247247 {
248+ // Avoid dispatching the event multiple times if our logger instance is the LogManager...
249+ if ($ this ->logger instanceof LogManager &&
250+ $ this ->logger ->getEventDispatcher () !== null ) {
251+ return ;
252+ }
253+
248254 // If the event dispatcher is set, we will pass along the parameters to the
249255 // log listeners. These are useful for building profilers or other tools
250256 // that aggregate all of the log messages for a given "request" cycle.
Original file line number Diff line number Diff line change 22
33namespace Illuminate \Tests \Integration \Log ;
44
5+ use Illuminate \Log \Events \MessageLogged ;
6+ use Illuminate \Log \Logger ;
7+ use Illuminate \Support \Facades \Event ;
58use Illuminate \Support \Facades \Log ;
69use Orchestra \Testbench \TestCase ;
710
@@ -13,4 +16,13 @@ public function testLoggingCanBeRunWithoutEncounteringExceptions()
1316
1417 Log::info ('Hello World ' );
1518 }
19+
20+ public function testCallingLoggerDirectlyDispatchesOneEvent ()
21+ {
22+ Event::fake ([MessageLogged::class]);
23+
24+ $ this ->app ->make (Logger::class)->debug ('my debug message ' );
25+
26+ Event::assertDispatchedTimes (MessageLogged::class, 1 );
27+ }
1628}
You can’t perform that action at this time.
0 commit comments