[5.6] More flexibility for custom log drivers#23184
Merged
Merged
Conversation
Contributor
|
Perhaps add a test? |
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.
I love the ability to have custom log drivers in config, without needing to call extend on drivers, and it reminded me of something very similar I was doing in an app as a way of specifying lazy values in config, by using callables (in particular, using the array notation since we cannot serialize closures).
So, the example at https://laravel.com/docs/5.6/logging#creating-custom-channels is great, and still works, but the following example now works also:
with a static function:
This is very simple, and you don't need to go through the service container. Moreover, you don't need to create a special class with an invoke method, you can just add a static method wherever you feel, even on the logger class itself.