Problem/Motivation
For exceptions, Drupal core passes the raw PHP backtrace to logger implementations. It does not do so for PHP errors, warnings, notices etc. so the logger must regenerate the backtrace if it needs one (as various third-party logging libraries such as Sentry do).
Proposed resolution
Include the backtrace in the $context array for errors, just like it is for exceptions.
Remaining tasks
Review change notice: https://www.drupal.org/node/2868845
User interface changes
None
API changes
Logger implementations will receive the backtrace for errors, in addition to exceptions.
Data model changes
None
Original report by mfb
Logger implementations could make use of the raw debug_backtrace() array, rather than having to regenerate it (which I'd assume uses extra memory and wastes CPU cycles).
I'm not clear why core unsets the backtrace - it may be doing so for no good reason - so testing out this patch to see if it passes tests.