Skip to content

Commit

Permalink
flush any log context after each operation (#337)
Browse files Browse the repository at this point in the history
  • Loading branch information
themsaid authored Jun 30, 2021
1 parent 7697ce1 commit 7c56189
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Concerns/ProvidesDefaultConfigurationOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public static function prepareApplicationForNextOperation(): array
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToValidationFactory::class,
\Laravel\Octane\Listeners\GiveNewApplicationInstanceToViewFactory::class,
\Laravel\Octane\Listeners\FlushDatabaseRecordModificationState::class,
\Laravel\Octane\Listeners\FlushLogContext::class,
\Laravel\Octane\Listeners\FlushArrayCache::class,

// First-Party Packages...
Expand Down
23 changes: 23 additions & 0 deletions src/Listeners/FlushLogContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Laravel\Octane\Listeners;

class FlushLogContext
{
/**
* Handle the event.
*
* @param mixed $event
* @return void
*/
public function handle($event): void
{
if (! $event->sandbox->resolved('log')) {
return;
}

if (method_exists($event->sandbox['log']->driver(), 'withoutContext')) {
$event->sandbox['log']->withoutContext();
}
}
}

0 comments on commit 7c56189

Please sign in to comment.