monolog
monolog copied to clipboard
Add stacktrace to PHP info/warning messages
I'm using
$formatter = new LineFormatter();
$formatter->includeStacktraces(true);
For PHP errors (like call to undefined functions) as well as Exceptions, stack traces are now included in the log. But for warnings like
E_WARNING: urlencode() expects parameter 1 to be string, array given
There is no stack trace, which makes it almost impossible to track the problem. Xdebug always shows stack traces, but of course that's only useful when developing.
I guess maybe this could be done by passing a new ErrorException into the context data in https://github.com/Seldaek/monolog/blob/master/src/Monolog/ErrorHandler.php and adjusting the stack trace generation to ignore the ErrorHandler frame from the stack trace when it is an ErrorException.
How about https://www.php.net/manual/en/function.debug-backtrace.php?