Skip to content

Commit

Permalink
Restrict trace events to correct log level (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
alecsammon authored Sep 25, 2024
1 parent 80afd21 commit e2ba8fa
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Instrumentation/Laravel/src/Watchers/LogWatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,23 @@ public function register(Application $app): void
{
/** @phan-suppress-next-line PhanTypeArraySuspicious */
$app['events']->listen(MessageLogged::class, [$this, 'recordLog']);

/** @phan-suppress-next-line PhanTypeArraySuspicious */
$this->logger = $app['log'];
}

/**
* Record a log.
*/
public function recordLog(MessageLogged $log): void
{
$underlyingLogger = $this->logger->getLogger();

/** @phan-suppress-next-line PhanUndeclaredMethod */
if (method_exists($underlyingLogger, 'isHandling') && !$underlyingLogger->isHandling($log->level)) {
return;
}

$attributes = [
'context' => json_encode(array_filter($log->context)),
];
Expand Down

0 comments on commit e2ba8fa

Please sign in to comment.