monolog icon indicating copy to clipboard operation
monolog copied to clipboard

Add stacktrace to PHP info/warning messages

Open m-ober opened this issue 5 years ago • 3 comments

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.

m-ober avatar Apr 07 '20 09:04 m-ober

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.

Seldaek avatar May 11 '20 13:05 Seldaek

How about https://www.php.net/manual/en/function.debug-backtrace.php?

stefanfisk avatar Aug 13 '20 18:08 stefanfisk