Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite branch: lump stack trace #10

Open
afragen opened this issue Aug 8, 2018 · 16 comments
Open

Rewrite branch: lump stack trace #10

afragen opened this issue Aug 8, 2018 · 16 comments

Comments

@afragen
Copy link

afragen commented Aug 8, 2018

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
Copy link
Author

afragen commented Aug 8, 2018

This one's gonna take some work.

@afragen
Copy link
Author

afragen commented Aug 8, 2018

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.

@norcross
Copy link
Owner

norcross commented Aug 8, 2018

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.

@afragen
Copy link
Author

afragen commented Aug 9, 2018

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?

@norcross
Copy link
Owner

norcross commented Aug 9, 2018

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

@stevegrunwell
Copy link

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

@lukecav
Copy link

lukecav commented Aug 9, 2018

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

@afragen
Copy link
Author

afragen commented Aug 9, 2018

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

@lukecav
Copy link

lukecav commented Aug 9, 2018

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

@norcross
Copy link
Owner

norcross commented Aug 9, 2018

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

@afragen
Copy link
Author

afragen commented Aug 9, 2018

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

It might simply be messing with the CSS from here.

@norcross
Copy link
Owner

norcross commented Aug 9, 2018

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.

@afragen
Copy link
Author

afragen commented Aug 10, 2018

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.

@norcross
Copy link
Owner

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
Copy link
Owner

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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants