Skip to content

Conversation

@Litarnus
Copy link
Contributor

@Litarnus Litarnus commented Jan 8, 2026

This PR extends the possible log level to properly handle the filtering of log messages.

Since sentry has fewer log levels than monolog, it wasn't possible to filter based on monolog levels because we would convert it losing some levels. With the changes in this PR, it will be possible to filter based on monolog levels and the severity will only be converted when sending to sentry.

@Litarnus Litarnus marked this pull request as ready for review January 13, 2026 12:17
}

public static function logLevelDataProvider(): iterable
public static function monologLegacyLevelDataProvider(): iterable
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests are maybe a bit too verbose and confusing, not sure

return $record['level'] >= $this->logLevel->value;
} else {
return $record['level'] >= $this->logLevel;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enum-to-int comparison fails in Monolog 3

High Severity

In Monolog 3, $record['level'] returns a \Monolog\Level enum object, not an integer. The comparisons on lines 59 and 61 attempt to compare this enum directly with integer values ($this->logLevel->value or $this->logLevel), which throws a TypeError in PHP 8.1+ since backed enums cannot be compared with integers using >=. The BreadcrumbHandler in the same codebase demonstrates the correct pattern: checking if ($level instanceof Level) and extracting $level->value before comparison.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants