Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem: Drupal only logs the current line for a PHP error or an exception. I want a backtrace to actually know where the error came from.
Proposed solution: log a lightweight backtrace with print_r() as additional watchdog() variable.
Comment | File | Size | Author |
---|---|---|---|
#8 | drupal-watchdog-backtrace-2654406-8-D7.patch | 2.84 KB | caschbre |
Comments
Comment #2
klausiPatch.
Comment #3
Alan D. CreditAttribution: Alan D. commentedAs the author wrote, the one being worked on core is too large and probably too slow on the uptake.
Comment #4
klausiLet's keep this open as an alternative to the other issue.
Comment #5
david_garcia CreditAttribution: david_garcia commentedIn D8 it is perfectly possible to deal with this from contrib without hacking core. That might be a better place for this to move on...
Comment #6
cilefen CreditAttribution: cilefen commentedIs this a duplicate of #2638140: Error logging should log a backtrace consistently?
Comment #7
gappleAn updated patch to keep up with a change to
_drupal_log_error()
Comment #8
caschbre CreditAttribution: caschbre as a volunteer commentedHere is an updated patch that uses several variables to optionally provide the "heavy" or "light" version. The previous patch calls debug_backtrace as the "heavy" version and then unsets array elements to make it light. The new patch uses the debug_backtrace $options parameter to do this which makes execution faster. This also gives the developer an option to output the object/args elements in the backtrace by setting a variable.
So instead of:
We have:
Comment #9
dalinDupe of #1158322: Add backtrace to all errors which has had much more activity on it.