debug-quick-look
debug-quick-look copied to clipboard
Rewrite branch: lump stack trace
It would be great to clump the entire PHP stack trace from PHP Notice or PHP Fatal through PHP Stack Trace and every identically timestamped line that follows.
[08-Aug-2018 02:28:22 UTC] PHP Notice: Undefined index: source in /Users/afragen/Documents/github/wp-debugging/vendor/afragen/wp-dependency-installer/wp-dependency-installer.php on line 427
[08-Aug-2018 02:28:22 UTC] PHP Stack trace:
[08-Aug-2018 02:28:22 UTC] PHP 1. {main}() /app/public/wp-admin/plugins.php:0
[08-Aug-2018 02:28:22 UTC] PHP 2. require_once() /app/public/wp-admin/plugins.php:459
[08-Aug-2018 02:28:22 UTC] PHP 3. do_action() /app/public/wp-admin/admin-header.php:267
[08-Aug-2018 02:28:22 UTC] PHP 4. WP_Hook->do_action() /app/public/wp-includes/plugin.php:465
[08-Aug-2018 02:28:22 UTC] PHP 5. WP_Hook->apply_filters() /app/public/wp-includes/class-wp-hook.php:310
[08-Aug-2018 02:28:22 UTC] PHP 6. WP_Dependency_Installer->admin_notices() /app/public/wp-includes/class-wp-hook.php:286
That whole trace could be a single div and sorted appropriately.
Maybe a regex from PHP Notice to PHP Notice or whatever that starting line happens to be.
Not easy I know.
Currently each line in it's own div and displayed in reverse.
This one's gonna take some work.
OK, I’ve got some working code that places all lines containing the identical time stamps into an array. This gives me an array of arrays instead of an array of lines. This should group everything somewhat chronologically but I’ve found instances where several stack traces occur at the same time stamp.
Naturally the formatting doesn’t work for this.
can you post an example of the debug file? the examples I was working with didn't have a date line on each portion of a stack trace.
Here's my local debug.log. https://gist.github.com/afragen/2e7658fb8e0337afb9432acd1f5f9d4a
Not sure how different others would be. Can you post example you're working with?
gonna see how many other examples I can get of logfiles so I can account for things. here's one I am working with: https://gist.github.com/norcross/f6e7da2b9c7cada87c17c84805af544f
This is taken from a debug.log on a VVV instance, and matches what @afragen is seeing:
[06-Jul-2018 15:32:54 UTC] PHP Warning: An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>. (WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.) in /srv/www/liquidweb-default/public_html/wp-includes/update.php on line 529
[06-Jul-2018 15:32:54 UTC] PHP Stack trace:
[06-Jul-2018 15:32:54 UTC] PHP 1. {main}() /srv/www/liquidweb-default/public_html/wp-cron.php:0
[06-Jul-2018 15:32:54 UTC] PHP 2. do_action_ref_array($tag = 'wp_update_themes', $args = array ()) /srv/www/liquidweb-default/public_html/wp-cron.php:126
[06-Jul-2018 15:32:54 UTC] PHP 3. WP_Hook->do_action($args = array ()) /srv/www/liquidweb-default/public_html/wp-includes/plugin.php:515
[06-Jul-2018 15:32:54 UTC] PHP 4. WP_Hook->apply_filters($value = '', $args = array ()) /srv/www/liquidweb-default/public_html/wp-includes/class-wp-hook.php:310
[06-Jul-2018 15:32:54 UTC] PHP 5. wp_update_themes($extra_stats = *uninitialized*) /srv/www/liquidweb-default/public_html/wp-includes/class-wp-hook.php:286
[06-Jul-2018 15:32:54 UTC] PHP 6. trigger_error('An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>. (WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)', 512) /srv/www/liquidweb-default/public_html/wp-includes/update.php:529
Another example debug log file if it helps. https://gist.github.com/lukecav/7c12ac66b3ab2e414872b8fc1b186fea
There seems to be lots of variation. Is anyone doing something to modify the output to their log?
No changes made to how the debug.log is being outputted.
nope. some of mine is old, but i imagine that different log functions and different environments may impact the formatting.
Seems like all the variations will be problematic in trying to group the errors.
It might simply be messing with the CSS from here.
I attempted to group multi-line things. I'm going to review the other examples of logfiles to see if I can find some consistency.
Unfortunately if we can't somehow consistently group the errors, I think reversing the order will be confusing.
Maybe some sort of regex from line before PHP Notice to next PHP Notice or whichever line is in the array $type in set_parse_block_class() to the next line in that array.
I’ve already reverted the sort order to default back to previous behavior.
I’ve also set it so the formatting functions are registered and called, and thus filterable. not sure that’s the final way I want to load it, but that’s the general way i plan on handling it. this may allow for people to address their own edge cases and formatting needs.
the longer I look at these differences, the more I think I may remove everything other than the very basic formatting (line breaks, encoding, etc) and work on the visual display
and looking like https://highlightjs.org/ may get me most of the way there