Skip to content

Commit

Permalink
chore(laravel): split shouldRecordLog method for easier override
Browse files Browse the repository at this point in the history
  • Loading branch information
flc1125 committed Oct 16, 2024
1 parent 7a48cd9 commit 1760bef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/Instrumentation/Laravel/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"lock": false,
"sort-packages": true,
"allow-plugins": {
"php-http/discovery": false
"php-http/discovery": false,
"tbachert/spi": true
}
}
}
17 changes: 13 additions & 4 deletions src/Instrumentation/Laravel/src/Watchers/LogWatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ public function register(Application $app): void
$this->logger = $app['log'];
}

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

Expand All @@ -41,6 +38,18 @@ public function recordLog(MessageLogged $log): void
&& method_exists($underlyingLogger, 'toMonologLevel')
&& !$underlyingLogger->isHandling($underlyingLogger->toMonologLevel($log->level))
) {
return false;
}

return true;
}

/**
* Record a log.
*/
public function recordLog(MessageLogged $log): void
{
if (!$this->shouldRecordLog($log)) {
return;
}

Expand Down

0 comments on commit 1760bef

Please sign in to comment.