debug-quick-look icon indicating copy to clipboard operation
debug-quick-look copied to clipboard

Rewrite branch: lump stack trace

Open afragen opened this issue 7 years ago • 16 comments
trafficstars

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.

afragen avatar Aug 08 '18 02:08 afragen

This one's gonna take some work.

afragen avatar Aug 08 '18 03:08 afragen

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.

afragen avatar Aug 08 '18 05:08 afragen

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.

norcross avatar Aug 08 '18 13:08 norcross

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?

afragen avatar Aug 09 '18 15:08 afragen

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

norcross avatar Aug 09 '18 15:08 norcross

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&#8217;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&#8217;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

stevegrunwell avatar Aug 09 '18 16:08 stevegrunwell

Another example debug log file if it helps. https://gist.github.com/lukecav/7c12ac66b3ab2e414872b8fc1b186fea

lukecav avatar Aug 09 '18 16:08 lukecav

There seems to be lots of variation. Is anyone doing something to modify the output to their log?

afragen avatar Aug 09 '18 18:08 afragen

No changes made to how the debug.log is being outputted.

lukecav avatar Aug 09 '18 19:08 lukecav

nope. some of mine is old, but i imagine that different log functions and different environments may impact the formatting.

norcross avatar Aug 09 '18 20:08 norcross

Seems like all the variations will be problematic in trying to group the errors.

It might simply be messing with the CSS from here.

afragen avatar Aug 09 '18 20:08 afragen

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.

norcross avatar Aug 09 '18 20:08 norcross

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.

afragen avatar Aug 10 '18 02:08 afragen

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.

norcross avatar Aug 10 '18 02:08 norcross

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

norcross avatar Aug 28 '18 17:08 norcross

and looking like https://highlightjs.org/ may get me most of the way there

norcross avatar Aug 28 '18 18:08 norcross