Skip to content

Commit e2ba8fa

Browse files
authored
Restrict trace events to correct log level (#264)
1 parent 80afd21 commit e2ba8fa

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Instrumentation/Laravel/src/Watchers/LogWatcher.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,23 @@ public function register(Application $app): void
2222
{
2323
/** @phan-suppress-next-line PhanTypeArraySuspicious */
2424
$app['events']->listen(MessageLogged::class, [$this, 'recordLog']);
25+
26+
/** @phan-suppress-next-line PhanTypeArraySuspicious */
27+
$this->logger = $app['log'];
2528
}
2629

2730
/**
2831
* Record a log.
2932
*/
3033
public function recordLog(MessageLogged $log): void
3134
{
35+
$underlyingLogger = $this->logger->getLogger();
36+
37+
/** @phan-suppress-next-line PhanUndeclaredMethod */
38+
if (method_exists($underlyingLogger, 'isHandling') && !$underlyingLogger->isHandling($log->level)) {
39+
return;
40+
}
41+
3242
$attributes = [
3343
'context' => json_encode(array_filter($log->context)),
3444
];

0 commit comments

Comments
 (0)