Added support for monolog/monolog v3 #602
Merged
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.
This PR adds support for Monolog v3. This is required to be compatible with Laravel v10. This was done without removing support for Monolog v2. I believe it is important to provide compatibility with existing packages that don't yet support Monolog v3.
Description of the change
The biggest changes are in the
Rollbar\Config
class. Monolog v3 changes the log level to anenum
. Enums are new in PHP 8.1. Previously, the log level was an integer. This may seem like a small issue. However, it has a number of implications.none
verbose log level with an integer value of1000
will not work.To resolve the first issue a number of checks were added so that Monolog v2 and v3 return types are both supported.
To resolve the second issue if the
'verbose'
config option is set to'none'
we set the verbose log hander to theNoopHandler
instead of trying to set the log level as1000
like we did previously.Lastly, we bumped the version of
vimeo/psalm
to v5 to support some of the new PHP 8.1 features from Monolog.Test Changes
There were some minor updates to the
ConfigTest
and `RollbarLoggerTest classes to support the above changes.The biggest changes in the tests were in the
VerbosityTest
class. It previously used a sophisticated series of mocks and lambda functions to validate that the right verbose messages were logged. The changes to support Monolog v3 caused all of these tests to fail. I believe it had something to do with theNoopHandler
in some of the cases, but I really don't know. After trying to debug theVerbosityTest
test suite for way too long (like an hour) I decided to remove the mocks and the anonymous functions and write more declarative test with the existingArrayLogger
test helper as the verbose logger. I added a few new methods toArrayLogger
and updated all the test. TheVerbosityTest
class is now about half the size, retains all the previous test cases, and last but most important to me I can read and understand it.Type of change
Related issues
Checklists
Development
Code review