Jump to content
adrian

Tracy Debugger

Recommended Posts

Ok, the PHP 5.3 issue should be fixed in TracyDebugger and a PR has been submitted for Performance panel as well.

  • Like 3

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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...

Edited by matjazp
  • Like 1

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Hey @ukyo - sorry about that - please try the latest version and let me know how it goes for you. That was actually some leftover code that wasn't needed anymore :)

  • Like 1

Share this post


Link to post
Share on other sites

With 0.9.8 version problem look like gone. Thanks for quick reply / fix !

  • Like 1

Share this post


Link to post
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

Share this post


Link to post
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/

Share this post


Link to post
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

Share this post


Link to post
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>?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Issue remains, but depends on template file:

<?php 
  echo $page->title;

is ok.

<?php 
  echo $page->title;
?>

is also ok.

<?php 
  echo $page->title;
?>
foo

is not ok.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

@matjazp - just letting you know that the latest version includes the fix for your problem. Could you please let me know if it works for you?

  • Like 1

Share this post


Link to post
Share on other sites

Yes, it works for me, I had to clean the templates cache.

One more thing: debug.innerHTML is "oneliner", with " \n\n" etc. How do you manage to debug that? :-)

  • Like 1

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By bernhard
      --- Please use RockFinder3 ---
    • By MoritzLost
      Cacheable Placeholders
      This module allows you to have pieces of dynamic content inside cached output. This aims to solve the common problem of having a mostly cacheable site, but with pieces of dynamic output here and there.  Consider this simple example, where you want to output a custom greeting to the current user:
      <h1>Good morning, <?= ucfirst($user->name) ?></h1> This snippet means you can't use the template cache (at least for logged-in users), because each user has a different name. Even if 99% of your output is static, you can only cache the pieces that you know won't include this personal greeting. A more common example would be CSRF tokens for HTML forms - those need to be unique by definition, so you can't cache the form wholesale.
      This module solves this problem by introducing cacheable placeholders - small placeholder tokens that get replaced during every request. The replacement is done inside a Page::render hook so it runs during every request, even if the response is served from the template cache. So you can use something like this:
      <h1>Good morning, {{{greeting}}}</h1> Replacement tokens are defined with a callback function that produces the appropriate output and added to the module through a simple hook:
      // site/ready.php wire()->addHookAfter('CachePlaceholders::getTokens', function (HookEvent $e) { $tokens = $e->return; $tokens['greeting'] = [ 'callback' => function (array $tokenData) { return ucfirst(wire('user')->name); } ]; $e->return = $tokens; }); Tokens can also include parameters that are parsed and passed to the callback function. There are more fully annotated examples and step-by-step instructions in the README on Github!
      Features
      A simple and fast token parser that calls the appropriate callback and runs automatically. Tokens may include multiple named or positional parameters, as well as multi-value parameters. A manual mode that allows you to replace tokens in custom pieces of cached content (useful if you're using the $cache API). Some built-in tokens for common use-cases: CSRF-Tokens, replacing values from superglobals and producing random hexadecimal strings. The token format is completely customizable, all delimiters can be changed to avoid collisions with existing tag parsers or template languages. Links
      Github Repository & documentation Module directory (pending approval) If you are interested in learning more, the README is very extensive, with more usage examples, code samples and usage instructions!
    • By Craig
      I've been using Fathom Analytics for a while now and on a growing number of sites, so thought it was about time there was a PW module for it.
      WayFathomAnalytics
      WayFathomAnalytics is a group of modules which will allow you to view your Fathom Analytics dashboard in the PW admin panel and (optionally) automatically add and configure the tracking code on front-end pages.
      Links
      GitHub Readme & documentation Download Zip Modules directory Module settings screenshot What is Fathom Analytics?
      Fathom Analytics is a simple, privacy-focused website analytics tool for bloggers and businesses.

      Stop scrolling through pages of reports and collecting gobs of personal data about your visitors, both of which you probably don't need. Fathom is a simple and private website analytics platform that lets you focus on what's important: your business.
      Privacy focused Fast-loading dashboards, all data is on a single screen Easy to get what you need, no training required Unlimited email reports Private or public dashboard sharing Cookie notices not required (it doesn't use cookies or collect personal data) Displays: top content, top referrers, top goals and more
    • By daniels
      This is a lightweight alternative to other newsletter & newsletter-subscription modules.
      You can find the Module in the Modules directory and on Github
      It can subscribe, update, unsubscribe & delete a user in a list in Mailchimp with MailChimp API 3.0. It does not provide any forms or validation, so you can feel free to use your own. To protect your users, it does not save any user data in logs or sends them to an admin.
      This module fits your needs if you...
      ...use Mailchimp as your newsletter / email-automation tool ...want to let users subscribe to your newsletter on your website ...want to use your own form, validation and messages (with or without the wire forms) ...don't want any personal user data saved in any way in your ProcessWire environment (cf. EU data regulation terms) ...like to subscribe, update, unsubscribe or delete users to/from different lists ...like the Mailchimp UI for creating / sending / reviewing email campaigns *I have only tested it with PHP 7.x so far, so use on owners risk
      EDIT:
      Since 0.0.4, instructions and changelog can be found in the README only. You can find it here  🙂
      If you have questions or like to contribute, just post a reply or create an issue or pr on github, thanks!
    • By MoritzLost
      Sorry for the convoluted title. I have a problem with Process modules that define a custom page using the page key through getModuleInfo (as demonstrated in this excellent tutorial by @bernhard). Those pages are created automatically when the module is installed. The problem is that the title of the page only gets set in the current language. That's not a problem if the current language (language of the superuser who is installing the module) is the default language; if it isn't, the Process page is missing a title in the default language. This has the very awkward effect that a user using the backend in the default language (or any other language) will see an empty entry in the setup menu:

      This screenshot comes from my Cache Control module which includes a Process page. Now I realize the description sounds obscure, but for us it's a common setup: We a multiple bilingual sites where the default language is German and the second language is English. While the clients use the CMS in German, as a developer I prefer the English interface, so whenever I install a Process module I get this problem.
      As a module author, is there a way to handle this situation? I guess it would be possible to use post-installation hooks or create the pages manually, but I very much prefer the declarative approach. The page title is already translatable (through the __ function), but of course at the time of installation there is no translation, and as far as I'm aware it's not possible to ship translations with a module so they are used automatically. Could this situation be handled better in the core? I would prefer if the module installation process would always set the title of the Process page in the default language, instead of the language of the current user.
×
×
  • Create New...