Fixed #461 Added support for psr/log context exception #582
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.
Description of the change
This change brings us up to compliance with the PSR-3 logging standard. PSR-3 requires an
Exception
in thecontext
array must be in theexception
key.For example, the following is a pretty standard non-exception log...
However, the PSR-3 standard expects us to be able to accept the following log...
Until now we have treated the
exception
key the same as any other key. Meaning we would not have created a stack trace of theException
. We only did that if theException
was themessage
.This change adds a check to determine if the
context
array contains anexception
key and it is aThrowable
. If it is we use that as ourException
when generating the trace. To retain as much backwards compatibility as possibleExceptions
can still be passed in as themessage
. In fact, this is the default behavior for our exception handler that automatically catches and logs uncaught exceptions.This does create a change in how we handle exceptions in the
$message
. If there is an exception in$context['exception']
we will ignore any exception in$message
. Instead, we take the string value of$message
and use it as thedescription
of the exception. Until now thedescription
was always omitted.The last additional change was to update some of our internal type annotations.
Type of change
Related issues
Checklists
Development
Code review