Skip to content
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

[6.x] Fix Monolog v2 handler instantiation #30123

Merged

Conversation

X-Coder264
Copy link
Contributor

Monolog 1 has the setFormatter method on the HandlerInterface while Monolog 2 extracted that method from the HandlerInterface to a FormattableHandlerInterface. This now means that a bunch of handlers in Monolog 2 don't have that method aka they are not formattable. The problem is that Laravel is calling the setFormatter method without checking if it actually exists on the handler when using Monolog 2 which causes an exception to be thrown.

This PR fixes the problem by checking for the FormattableHandlerInterface if Monolog 2 is being used. A test has also been added which tests the instantiation of a logger which has the NullHandler handler which is no longer formattable in Monolog 2. This test will be run with Monolog 1 in the CI with the low deps option and with Monolog 2 in the newest deps pipeline so it confirms that the instantiation now works with both Monolog versions. This test of course doesn't pass without the fix in this PR.

Fixes #30026

@X-Coder264 X-Coder264 changed the title Fix Monolog v2 handler instantiation [6.x] Fix Monolog v2 handler instantiation Sep 27, 2019
@taylorotwell taylorotwell merged commit 6ce1602 into laravel:6.x Sep 30, 2019
@X-Coder264 X-Coder264 deleted the fix-monolog-handler-instantiation branch September 30, 2019 13:02
i-bajrai pushed a commit to i-bajrai/framework that referenced this pull request Oct 4, 2019
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.

[6.0] Monolog Channel can't use NullHandler in Monolog 2.0
3 participants