Jump to content

Tracy Debugger


adrian

Recommended Posts

Some more improvements:

Fields List and Values section on the PW Info panel

Take a look at the "images" field in the screeshot - much cleaner and more informative.

I have populated all the files/images related properties: filename, ext, url, httpUrl, filesize, filesizeStr, width, height, description, etc. Think of it as a cheatsheet with properties and values built right in. I have also added formatted dates and user names in parentheses for reference.

post-985-0-25555700-1456797445_thumb.png

Variables Panel

I have also recently tweaked the Variables panel to be easier to read and to separate into columns with the variable name, its type, and value:

post-985-0-89696500-1456797753_thumb.png

Development Tip

One final thing - a bit of a development tip using Tracy - want a quick way to see the results of a PW selector?

Try this out in one of your template files:

bd($pages->find("template=basic-page")->explode('name'));

You will see something like this in your Dumps panel:

post-985-0-21138400-1456797893_thumb.png

On a live site in production mode, it pays to do it like this:

if($user->isSuperuser()) bd($pages->find("template=basic-page")->explode('name'));

This way, even if your selector generates an exception (quite easy to do if you accidentally enter an incorrect field name), no-one but you will see the error.

  • Like 4
Link to comment
Share on other sites

Now I get (in Diag & Output panel):

PDOException: SQLSTATE[HY000] [2002] Nobene povezave ni mogoe vzpostaviti, ker jo ciljni raunalnik aktivno zavraa.
in C:\inetpub\wwwroot\site\assets\cache\FileCompiler\site\modules\TracyDebugger\DiagnosticsPanel.inc:287
Stack trace:
#0 C:\inetpub\wwwroot\site\assets\cache\FileCompiler\site\modules\TracyDebugger\DiagnosticsPanel.inc(287): PDO->__construct('mysql:host=loca...', 'myusername', 'mypassword')
#1 C:\inetpub\wwwroot\site\assets\cache\FileCompiler\site\modules\TracyDebugger\tracy\src\Tracy\Bar.php(73): DiagnosticsPanel->getPanel()
#2 C:\inetpub\wwwroot\site\assets\cache\FileCompiler\site\modules\TracyDebugger\tracy\src\Tracy\Debugger.php(221): Tracy\Bar->render()
#3 [internal function]: Tracy\Debugger::shutdownHandler()
#4 {main}

It shows user/pass for DB in plain view...

A also can't move some panels, see the video.

post-2202-0-57364600-1456802881_thumb.gi

Edited by matjazp
  • Like 2
Link to comment
Share on other sites

Sorry about the database connection error. There was a problem with some attributes and the PW $database connection, but I have removed those two problem ones and now use $database. Please let me know if it is working properly again now with the latest version.

I know about the panel moving issue - some do that weird resizing before they will move. It is on my list of things to take a look at - not sure if it's maybe a core Tracy issue, but I'll try to sort it out regardless.

  • Like 1
Link to comment
Share on other sites

No luck with the new version, error is stil there.

Hm, it's working now ... don't know what I did...

Glad it's working fine now - please let me know if you come across any other problems with that.

Link to comment
Share on other sites

Thanks for the new releases! I get used to it recently, updating Tracy when having the morning coffee :)

Adding an "in-panel search as you type" feature would be handy I think. Basically I mean a search input above the panel tables (one per panel), in which if you start typing the table non-matching rows would get hidden.

The problem is that not all panels have tables but divs.

  • Like 1
Link to comment
Share on other sites

After update to version 0.9.7 i have this error :

Fatal error: Call to a member function getImageInfo() on a non-object in /......./......./......./......./site/assets/cache/FileCompiler/site/modules/TracyDebugger/ProcesswireInfoPanel.inc on line 259 

Tracy panel not appear for front-end and if i comment this line it look like working.

PW version : ProcessWire 3.0.9 devns

Link to comment
Share on other sites

Hi everyone,

I have just set up the ability to customize the potocol handler for opening files in your editor directly to the line of error - this is potentially a huge timesaver :)

The new config setting is "Editor Protocol Handler":

post-985-0-31774400-1456895869_thumb.png

It is initially configured for SublimeText because that is my editor and I know lots of you also use it.

To make things work, grab this free subl:// protocol registering app: https://github.com/saetia/sublime-url-protocol-mac - note the instructions at the bottom if you need to make it work for ST2 instead of ST3. If you're not using ST, there are other ways to set up your own custom protocol handler, but I'l leave you guys to figure that out.

Once you have done that you will be able to click on any of the links in errors, dumps, and barBumps and it will open the file in ST to the exact line.

post-985-0-99120100-1456932310_thumb.png

post-985-0-86665200-1456932311_thumb.png

post-985-0-78615100-1456932309_thumb.png

 

Note: the links are to the actual original files, not the PW 3.x compiled versions !

  • Like 3
Link to comment
Share on other sites

The Editor Protocol Handler would be great, but I have problems with escaped characters like / as %2F. The links look like this:

openineclipse://open?url=file://%2FLibrary%2FWebServer%2FDocuments%2Fpw25%2Fsite%2Ftemplates%2Fhome.php&line=25

But in Safari at least this doesn't work if I don't change each "%2F" to "/".  How could I change the links to be like:

openineclipse://open?url=file:///Library/WebServer/Documents/pw25/site/templates/home.php&line=25

or get Safari or Chrome understand 

I found help on defining the Editor Protocol Handler for Eclipse "openineclipse" on this page: http://teleyag.com/blog/2011/08/19/openineclipse-url-scheme-for-mac/

Link to comment
Share on other sites

Hi @Ipa,

It's working fine for me on Safari, Chrome, and Firefox on my Mac with Sublime so I am guessing it's an eclipse issue. 

I wonder if it could be solved in your applescript with the urldecode line from this snippet?

using terms from application "Quicksilver"
        on process text theurl
                return do shell script "php -r 'echo urldecode(\"" & theurl & "\");'"
        end process text
end using terms from

https://qsapp.com/wiki/Encode/Decode_URL_(AppleScript)

or maybe one of these options:

http://harvey.nu/applescript_url_decode_routine.html

http://macscripter.net/viewtopic.php?id=3675

If that doesn't work, here is the route of the "problem": https://github.com/adrianbj/TracyDebugger/blob/master/tracy/src/Tracy/Helpers.php#L49

Of course that is part of the Tracy core so I'd rather not edit it. I did however test with Sublime by removing the `rawurlencode` on that line and it works fine. Maybe if you can't get Eclipse to work, you could post on the Tracy forums to see if they would remove the encoding, although I expect it is important if there are spaces in the path?

I'd actually like to start compiling a list of resources for all of the various editors and platforms. I will add these to the module's readme as they are provided by you guys!

  • Like 1
Link to comment
Share on other sites

I see this in browser's View source:

</body>
</html>

?>

<!-- Tracy Debug Bar -->




<script>
(function() {...

There is unexpected "?>" but only in front end, not in backend. Also, is it ok to have script after the </html>?

Link to comment
Share on other sites

The position of the Tracy script after </html> might be a little weird - I am not sure their reasoning for this, but it's definitely a core Tracy thing, rather than an issue with this module. Take at look at their demo page and you'll notice the same thing: https://nette.github.io/tracy/tracy-exception.html

As for the extra "?>" - that looks to be related to the Variables panel - I am injecting code into the end of the compiled template files to make this work. I thought my regex was handling all scenarios, but perhaps not. Could you please try clearing your FileCompiler templates cache and let me know if the issue remains. If it does, please post the last few lines of your template file so I can test here and fix it.

  • Like 1
Link to comment
Share on other sites

Thanks @matjazp - that helped - I had forgotten to consider text after the last closing php tag.

I have a fix that is working here. I have something else I am working on with Tracy right now so I'll commit both things fairly soon.

  • Like 2
Link to comment
Share on other sites

Glad to hear it's working for you - hopefully this new approach will work in all scenarios.

As for debugging debug.innerHTML - I haven't had to debug it yet - it's mostly generated by Tracy anyway. Being a JS variable, there isn't really an easy way of making it multiline without concatenation, which really isn't worth the trouble in this case. I am looking forward to Template Literals in ES6 though - we'll finally have real multiline variables for JS.

But, back to your question, - if you do need to debug code like that you can use the regex find & replace option in your editor to replace \\n with \n and \\t with \t and it will be fully formatted.

In Sublime Text (in case you use that), click the asterisk in the find and replace box - super easy!

  • Like 1
Link to comment
Share on other sites

Small update that enhances links from the PW Info panel Summary section - now you can have shortcuts to either view (page name) or edit (page id) each of the linked pages that are related to the current page.

The children item now has:

  • an "open tree" link (opens this page in the page tree expanded to show all children)
  • an "edit" link (opens this page to the Children tab, which is particularly useful if you have Batch Child Editor installed).

The template filename in the Template Info section uses the defined editor protocol handler to open the file directly in your code editor.

Hopefully you'll all find these nice little time/click savers :)

post-985-0-62155000-1457205386_thumb.png

And page edit and template file edit buttons are also in the footer of this panel for instant access:

post-985-0-04478800-1457207052_thumb.png

  • Like 6
Link to comment
Share on other sites

New public method:

TD::templateVars()
templateVars()
tv()

Basically what this does is strip any system PW variables and returns just those that you have defined in your template file. It replicates what is output on the "Variables" panel, but lets you dump, barDump, fireLog, or log at whatever points you want throughout the execution of your template file script. Obviously if you are only interested in the changes to one variable there is no point in using this, but if you want to see how they all change, this is a nice shortcut.

It is really only designed to work with PHP's get_defined_vars()

Here's an example output via barDump: bd()

$i=0;
$x=10;
bd(tv(get_defined_vars()), 'breakpoint one');
$i++;
$x--;
bd(tv(get_defined_vars()), 'breakpoint two');

This results in:

post-985-0-34988500-1457279330_thumb.png

Without tv() in there it would include all PW variables/objects and it would be difficult to see the variables you are interested in.

Note that the templateVars() and tv() shortcuts/aliases may need to be turned on in the config settings if you are upgrading.

  • Like 4
Link to comment
Share on other sites

You can now click on the text of any entry in the PW and Tracy log panels to open the file in your code editor to the line number of the clicked entry.

Of course for this to work, you need to have properly configured your editor protocol handler.

Not really worthy of a screenshot, but still a very handy shortcut that I hope you'll find useful for when you have an log entry that has been truncated because it's too long for the built-in viewer.

  • Like 1
Link to comment
Share on other sites

Note: the links are to the actual original files, not the PW 3.x compiled versions !

Hello adrian,

Thank you very much again for the new feature!

I have just found the time to test out this protocol handler thingy, and with the following configuration string it seems to work well with PhpStorm Mac:

phpstorm://open?file=%file&line=%line

However, it does open the compiled file in cache instead of the original ones.

Do you have any ideas why?

  • Like 1
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...