fix(logs): Allow passing string and enum Monolog level#959
Merged
Conversation
HypeMC
commented
Sep 18, 2025
| <code><![CDATA[isMasterRequest]]></code> | ||
| </UndefinedMethod> | ||
| </file> | ||
| <file src="src/Monolog/LogsHandler.php"> |
Contributor
Author
There was a problem hiding this comment.
Seems to be a bug in Psalm when using const on enums: https://psalm.dev/r/a6f9298b82
Litarnus
reviewed
Sep 22, 2025
Contributor
Litarnus
left a comment
There was a problem hiding this comment.
Thanks for your contribution, it makes a lot of sense to allow string levels!
| */ | ||
| public function __construct($level = MonologLogger::DEBUG, bool $bubble = true) | ||
| { | ||
| $level = MonologLogger::toMonologLevel($level); |
Contributor
There was a problem hiding this comment.
This will throw if an invalid level is passed. Please default to Info in such a case like getSentryLogLevelFromMonologLevel does. Also this would benefit from a test case.
Contributor
Author
1e072fc to
de332aa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Currently, the constructor only accepts integers as the log level, e.g. by using the
Monolog\Loggerconstants:This, however, isn't very flexible, especially since the Monolog constants are deprecated.
This PR expands the accepted types to also allow strings or the Monolog
Levelenum, like other handlers: