PsrMessage DTO for extended context handling #17
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.
PSRTarget is currently cast a logged message to a string, and there is no way to pass the context in any way since Yii does not intend to add the context to the message from outside.
The new DTO solves this problem by, on the one hand, adding the ability to transmit both message and additional context at the same time, and, on the other hand, leaving the ability to use itself for standard Yii log targets by implementing __toString method.
Usage example:
Now we can add additional context to our messages (and use PSR-3 placeholders populated by our context data):