-
Notifications
You must be signed in to change notification settings - Fork 185
fix(logs): Allow passing string and enum Monolog level #959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
<code><![CDATA[isMasterRequest]]></code> | ||
</UndefinedMethod> | ||
</file> | ||
<file src="src/Monolog/LogsHandler.php"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to be a bug in Psalm when using const on enums: https://psalm.dev/r/a6f9298b82
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution, it makes a lot of sense to allow string levels!
src/Monolog/LogsHandler.php
Outdated
*/ | ||
public function __construct($level = MonologLogger::DEBUG, bool $bubble = true) | ||
{ | ||
$level = MonologLogger::toMonologLevel($level); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1e072fc
to
de332aa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thank you!
Description
Currently, the constructor only accepts integers as the log level, e.g. by using the
Monolog\Logger
constants: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
Level
enum, like other handlers: