Skip to content

Commit 7c56189

Browse files
authored
flush any log context after each operation (#337)
1 parent 7697ce1 commit 7c56189

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/Concerns/ProvidesDefaultConfigurationOptions.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public static function prepareApplicationForNextOperation(): array
4545
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToValidationFactory::class,
4646
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToViewFactory::class,
4747
\Laravel\Octane\Listeners\FlushDatabaseRecordModificationState::class,
48+
\Laravel\Octane\Listeners\FlushLogContext::class,
4849
\Laravel\Octane\Listeners\FlushArrayCache::class,
4950

5051
// First-Party Packages...

src/Listeners/FlushLogContext.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Laravel\Octane\Listeners;
4+
5+
class FlushLogContext
6+
{
7+
/**
8+
* Handle the event.
9+
*
10+
* @param mixed $event
11+
* @return void
12+
*/
13+
public function handle($event): void
14+
{
15+
if (! $event->sandbox->resolved('log')) {
16+
return;
17+
}
18+
19+
if (method_exists($event->sandbox['log']->driver(), 'withoutContext')) {
20+
$event->sandbox['log']->withoutContext();
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)