Jump to content

Tracy Debugger


adrian

Recommended Posts

Stoked about the new documentation site! I love it even more with the text size zoomed to 125% ;)

In due course it would be great to add a section about barDumpLive() / bdl() - I've never been clear on when it's okay to use this and when it should be avoided due to the dumped variable getting mixed up. I use it from time to time and when there is a variable mix-up it's usually pretty obvious, in which case I switch to bd() with max depth and max length options included. Although I still worry there might be situations where the mix-up is more subtle and could lead to confusion.

Related to this: what do you think about adding a new shortcut method for "big" bardumps? This could have options in the module config for max depth and max length. Just so there's a quick way to do a bardump where you need greater nesting depth and string length than with the standard bd(). I have added a custom shortcut in my IDE for inserting a bd() with max depth and length options, but it would be cool to have something like a "bdb()" method in Tracy (until the barDumpLive thing is resolved anyway).

 

  • Like 2
Link to comment
Share on other sites

1 hour ago, Robin S said:

I love it even more with the text size zoomed to 125%

Taken care of that here - will push with the next update.

 

1 hour ago, Robin S said:

In due course it would be great to add a section about barDumpLive() / bdl()

Agreed - it will be in there with details and warnings. I am sure if it will ever be 100% reliable because of the way it works, but from my experience it only ever seems to be an problem when used within hooks.

 

1 hour ago, Robin S said:

but it would be cool to have something like a "bdb()"

I see two possibilities here :

  • a bdb() with some config settings to determine what the depth and length will be - I think the defaults should probably be 6 and 999 - any thoughts?
  • or a simplified syntax for bd(), eg bd($page, [6, 999]) so you don't have to do bd($page, ['maxDepth' => 6, 'maxLength' => 999]) which is painful

The problem with a fixed dbd() is that in the case of PW objects, anything more than 6 can results in out of memory errors (at least with my dev machine setup), but working with smaller objects/arrays, I often want 6 or 7.

I have decided to go with this for now, which sets the maxDepth to 6. Obviously pre PHP 5.4 you will still need: array(6)

bd($page, [6]);

You still need to make the depth and length settings an array - this is because the second argument in the array can either be the "title" or the options array. It's get too confusing to take it any further away from that default.

You can also do:

bd($page, [6,999]);

or:

bd($page, 'Dump Title', [6,999]);

How does that look to you?

I'll post this to the closed beta version shortly.

  • Like 2
Link to comment
Share on other sites

1 hour ago, Robin S said:

what do you think about adding a new shortcut method for "big" bardumps?

great idea, thx! needed that several times and maxLength=>... was a pain

9 minutes ago, adrian said:

anything more than 6 can results in out of memory errors (at least with my dev machine setup), but working with smaller objects/arrays, I often want 6 or 7.

10 minutes ago, adrian said:

bd($page, 'Dump Title', [6,999]);

How does that look to you?

would it be hard to have the shortcut bdb() for bd($page, [6,999]) ?

i think it would totally be fine to have that shortcut with fixed values since we have the other option of defining it manually like you showed above. but i think in 99% of the cases the bdb() would work just well and it is less to write and a lot easier to remember :)

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

It's been out for about 10 days now, but I never really announced the changes here - wanted to see if there were any issues before publicizing.

The new 4.9.x version is now available.

Here's a list of the main changes:

1) New File Editor Panel

  • Supports editing all files in your PW install (you can define the root as /, /site, or /site/templates
  • Can be used as the handler for opening editor links from the debug bar (errors, log files, Captain Hook, ToDo, Template editor, etc), rather than your code editor.
  • Can be enabled as the link handler for live sites only, or local as well if you prefer.
  • Has "Test" functionality for all files so if you make a change, it will only appear for you and not other users.
  • Makes a backup of the old version each time you save a change and provides a "Restore Backup" button to instantly revert.
  • Supports in-code search & replace with CMD+F
  • Syntax highlighting/linting for PHP, CSS, and JS
  • This replaces the Template Editor panel, so that one has been removed.
  • Handles fatal errors gracefully - this is the biggest feature in my opinion. The problem with most online file editors is that if you accidentally make a code change that results in a fatal error, it can be impossible to fix and resave because the system is not functional. This editor gets around this problem by using Tracy's custom error handling which allows debug bar panels to continue to work, so you can manually fix the problem, or click the "Restore Backup" button. Of course if you used the "Test" option, you don't even need to worry, because you are the only one to see the version with the error anyway.

image.thumb.png.050d883e2f50b8359e5a84e4524515c0.png

As a follow up to that last point. I have used the excellent ProcessFileEdit module for helping to debug some issues on other people's sites without needing FTP access, but a couple of times I have made a fatal error mistake and had to get them to restore the file, so this really is a huge feature for me!

 

2) Support for Process File Edit

If you prefer ProcessFileEdit to this new File Editor Panel, so you can use it for handling debug bar links. Note that this won't give you the "Test" and "Restore" options, or the fatal error protection, so it's not really recommended. I added support for it before building the File Editor panel so decided to leave in case others prefer it.

3) Revamped Console Panel 

  • The code and results sections are now a "split" screen so you can adjust the size of one relative to the other with the bar in the middle. Handy for working, but especially handy when you want to post a screenshot to the forums
  • "Large and "Small" versions of the panel - click the arrows at the top right of the panel - the large version can be very handy when you have lots of code or results to display
  • Supports in-code search & replace with CMD+F

image.thumb.png.5f60f96951818223b0ba520e27643b56.png


4) New maxDepth and maxLength shortcuts and new barDumpBig() method

You can now replace dump or barDump calls like:

bd($var, array('maxDepth' => 7, 'maxLength' => 500));

with:

bd($var, [7,500]);

You can also make use of the new:

bdb($var);

as a shortcut to:

bd($var, [6,999]);

 

5) New SQL Query column in the Selector Queries section of the Debug Mode panel

This is a great learning tool to see the selector queries that are run for a given page request, and what SQL query these selectors are translated into:

image.thumb.png.6fba1698525c64823aa14d5c95c60937.png

 

6) Removed old Legacy version of Tracy core

  • It was getting too painful to maintain support for this old version. This means that TD now requires PHP 5.4.4+

7) Namespacing and refactoring lots of Javascript code

  • No feature changes, but code is now easier to follow and is much less prone to any name conflicts with your site

8) Reduced loading of unnecessary code

  • Lots of refactoring here too - should see some performance gains

9) New default server type indicator in the debug bar 

  • Not a big deal, but if you want a server type indicator and don't want the full height/width bar, you can now have one in the debug bar - I think it's a handy visual clue when looking at /working on live vs dev/test versions of a site at the same time.

image.png.fee9a07fbf469adfa336dcc06fa9f47b.png

 

10) Lots and lots of bugs fixes, layout, and styling improvements

  • It's amazing what you find when you're buried in the code for a couple of weeks solid :)
     

11) The new docs site that I mentioned earlier is now fairly complete - I just need to work on the Tips & Tricks section

  • https://adrianbj.github.io/TracyDebugger
  • Feel free to make a PR for improvements to the docs - everything is under the /docs folder in the main Github repo. There are also "Edit on github" links on each page so you can use those as well.
  • Like 13
Link to comment
Share on other sites

JSON API response testing in the Console panel

I know we all know about json_decode($var, true), but here's a useful tip when working with APIs that return JSON.

Note that I am using the new shortcut for specifying a depth of 7 so I get to the deeper levels of the JSON response.

 

image.png.308bf5e4ecff17b0028200ed3d360439.png

 

Obviously that's a LOT nicer than:

image.png.49d3b2d1fe32a5950e604a8f609d5b22.png

 

  • Like 6
Link to comment
Share on other sites

New version just committed that is a must for Windows users - a huge thanks to @matjazp for the report and also local access to his dev machine so I could find and fix all the issues. You Windows guys need to speak up when you see issues ;) - the Console, Snippet Runner, and Captain Hook panels in particular were a mess :) Please let me know if you see anything I have missed.

Other changes include:

  • Add custom register_shutdown_function() for Console and Snippet Runner panels - especially important for PHP 5.x. PHP 7 handles most errors as non-fatal.
  • Fix AJAX panel updating for Console/Snippet Runner when SessionHandlerDB not installed.
  • A few styling fixes.
  • Like 4
Link to comment
Share on other sites

11 minutes ago, adrian said:

the Console, Snippet Runner, and Captain Hook panels in particular were a mess

Nothing obviously wrong/messy with those panels for me with v4.9.9 on Windows 8.1. Maybe some other factor comes into it. Thanks for the update though!

  • Like 1
Link to comment
Share on other sites

5 minutes ago, Robin S said:

Nothing obviously wrong/messy with those panels for me with v4.9.9 on Windows 8.1

Interesting - the key thing was incorrect line numbers on errors when running code in Console/Snippet Runner. And with Captain Hook panel it was a lack of grouping of file under the Site Modules headings. Maybe PHP on different version of Windows IIS handle forward / back slashes differently. All the issues came down to using strpos() to see if the path to a file contained a certain subpath, eg /site/modules - the trouble being that on Windows, I had to look for \site\modules instead. I fixed things with a combination of DIRECTORY_SEPARATOR and in some cases converting the paths to all forward slashes before doing checks, displaying links etc.

Thanks for keeping an eye out for any persistent / new issues.

Link to comment
Share on other sites

Another useful update - the File Editor panel now remembers and reopens the folder tree to the currently open file and highlights that file. Should make navigation to related files much simpler after save when the page reloads.

  • Like 2
Link to comment
Share on other sites

10 hours ago, tpr said:

Shadow DOM sounds like the ideal treat for Tracy bar encapsulation headaches,  when it will widely supported:

https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_shadow_DOM

When you say "encapsulation headaches" are you talking mostly about css inheritance?

Sorry, I haven't had a good read of that link yet :)

Link to comment
Share on other sites

Just now, tpr said:

Yes, having a separated DOM inside the main DOM, with its fully separated CSS.

Sounds awesome - thanks for the heads up. I wonder how hard it will be to implement and whether it really needs to be implemented in the Tracy core or not?

Link to comment
Share on other sites

  • adrian pinned and locked this topic
  • adrian unpinned and pinned this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...