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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By adrian
      This module allows you to automatically rename file (including image) uploads according to a configurable format
      This module lets you define as many rules as you need to determine how uploaded files will be named and you can have different rules for different pages, templates, fields, and file extensions, or one rule for all uploads. Renaming works for files uploaded via the admin interface and also via the API, including images added from remote URLs.   Github: https://github.com/adrianbj/CustomUploadNames
      Modules Directory: http://modules.processwire.com/modules/process-custom-upload-names/
      Renaming Rules
      The module config allows you to set an unlimited number of Rename Rules. You can define rules to specific fields, templates, pages, and file extensions. If a rule option is left blank, the rule with be applied to all fields/templates/pages/extensions. Leave Filename Format blank to prevent renaming for a specific field/template/page combo, overriding a more general rule. Rules are processed in order, so put more specific rules before more general ones. You can drag to change the order of rules as needed. The following variables can be used in the filename format: $page, $template, $field, and $file. For some of these (eg. $field->description), if they haven't been filled out and saved prior to uploading the image, renaming won't occur on upload, but will happen on page save (could be an issue if image has already been inserted into RTE/HTML field before page save). Some examples: $page->title mysite-{$template->name}-images $field->label $file->description {$page->name}-{$file->filesize}-kb prefix-[Y-m-d_H-i-s]-suffix (anything inside square brackets is is considered to be a PHP date format for the current date/time) randstring[n] (where n is the number of characters you want in the string) ### (custom number mask, eg. 001 if more than one image with same name on a page. This is an enhanced version of the automatic addition of numbers if required) If 'Rename on Save' is checked files will be renamed again each time a page is saved (admin or front-end via API). WARNING: this setting will break any direct links to the old filename, which is particularly relevant for images inserted into RTE/HTML fields. The Filename Format can be defined using plain text and PW $page variable, for example: mysite-{$page->path} You can preserve the uploaded filename for certain rules. This will allow you to set a general renaming rule for your entire site, but then add a rule for a specific page/template/field that does not rename the uploaded file. Just simply build the rule, but leave the Filename Format field empty. You can specify an optional character limit (to nearest whole word) for the length of the filename - useful if you are using $page->path, $path->name etc and have very long page names - eg. news articles, publication titles etc. NOTE - if you are using ProcessWire's webp features, be sure to use the useSrcExt because if you have jpg and png files on the same page and your rename rules result in the same name, you need to maintain the src extension so they are kept as separate files.
      $config->webpOptions = array(     'useSrcExt' => false, // Use source file extension in webp filename? (file.jpg.webp rather than file.webp) ); Acknowledgments
      The module config settings make use of code from Pete's EmailToPage module and the renaming function is based on this code from Ryan: http://processwire.com/talk/topic/3299-ability-to-define-convention-for-image-and-file-upload-names/?p=32623 (also see this post for his thoughts on file renaming and why it is the lazy way out - worth a read before deciding to use this module). 
       
       
      NOTE:
      This should not be needed on most sites, but I work with lots of sites that host PDFs and photos/vectors that are available for download and I have always renamed the files on upload because clients will often upload files with horrible meaningless filenames like:
      Final ReportV6 web version for John Feb 23.PDF

    • By Mike Rockett
      Jumplinks for ProcessWire
      Release: 1.5.56
      Composer: rockett/jumplinks
      Jumplinks is an enhanced version of the original ProcessRedirects by Antti Peisa.
      The Process module manages your permanent and temporary redirects (we'll call these "jumplinks" from now on, unless in reference to redirects from another module), useful for when you're migrating over to ProcessWire from another system/platform. Each jumplink supports wildcards, shortening the time needed to create them.
      Unlike similar modules for other platforms, wildcards in Jumplinks are much easier to work with, as Regular Expressions are not fully exposed. Instead, parameters wrapped in curly braces are used - these are described in the documentation.
      Under Development: 2.0, to be powered by FastRoute
      As of version 1.5.0, Jumplinks requires at least ProcessWire 2.6.1 to run.
      View on GitLab
      Download via the Modules Directory
      Read the docs
      Features
      The most prominent features include:
      Basic jumplinks (from one fixed route to another) Parameter-based wildcards with "Smart" equivalents Mapping Collections (for converting ID-based routes to their named-equivalents without the need to create multiple jumplinks) Destination Selectors (for finding and redirecting to pages containing legacy location information) Timed Activation (activate and/or deactivate jumplinks at specific times) 404-Monitor (for creating jumplinks based on 404 hits) Additionally, the following features may come in handy:
      Stale jumplink management Legacy domain support for slow migrations An importer (from CSV or ProcessRedirects) Feedback & Feature Requests
      I’d love to know what you think of this module. Please provide some feedback on the module as a whole, or even regarding smaller things that make it whole. Also, please feel free to submit feature requests and their use-cases.
      Note: Features requested so far have been added to the to-do list, and will be added to 2.0, and not the current dev/master branches.
      Open Source

      Jumplinks is an open-source project, and is free to use. In fact, Jumplinks will always be open-source, and will always remain free to use. Forever. If you would like to support the development of Jumplinks, please consider making a small donation via PayPal.
      Enjoy! :)
    • By BitPoet
      As threatened in Ryan's announcement for 3.0.139, I built a little module for sliding toggles as a replacement for checkboxes. Styling of the input is CSS3 only (with all the usual caveats about older browsers), no JS necessary, and may still be a bit "rough around the edges", so to speak, since I didn't have much time for testing on different devices or brushing things up enough so I'd feel comfortable pushing it to the module directory. But here's the link to the GitHub repo for now:
      InputfieldSlideToggle
      Fieldtype and Inputfield that implements smartphone-style toggles as replacement for checkbox inputs. The visualization is CSS-only, no additional JS necessary.
      Status
      Still very alpha, use with caution!
      Features / Field Settings
      Size
      You can render the toggles in four different sizes: small, medium, large and extra large.
      Off Color
      Currently, "unchecked" toggles can be displayed either in grey (default) or red.
      On Color
      "Checked" toggles can be rendered in one of these colors: blue (default), black, green, grey, orange or red.
      Screenshots

      Some examples with checkbox label


      View all Size and Color Combinations
      Small toggles Medium toggles Big toggles Extra big toggles  









    • By Orkun
      Hi Guys
      I needed to add extended functionalities for the InputfieldDatetime Module (module is from processwire version 2.7.3) because of a Request of Customer.
      So I duplicated the module and placed it under /site/modules/.
      I have added 3 new Settings to the InputfieldDatetime Module.
      1. Day Restriction - Restrict different days based on weekdays selection (e.g. saturday, sunday) - WORKING

       
      2. Time Slots - Define Time slots based on custom Integer Value (max is 60 for 1 hour) - WORKING

       
      3. Time Range Rules per Weekday - Define a minTime and MaxTime per Weekday (e.g. Opening Hours of a Restaurant) - NOT WORKING PROPERLY

       
      The Problem
      Time Slots and Day Restriction working fine so far. But the Time Range Rules per Weekday doesn't work right.
      What should happen is, that when you click on a date, it should update the minTime and maxTime of the Time Select.
      But the change on the select only happens if you select a date 2 times or when you select a date 1 time and then close the datepicker and reopen it again.
      The time select doesn't get change when you select a date 1 time and don't close the picker.
      Here is the whole extended InputfieldDatetime Module.
      The Files that I have changed:
      InputfieldDatetime.module InputfieldDatetime.js jquery-ui-timepicker-addon.js (https://trentrichardson.com/examples/timepicker/) - updated it to the newest version, because minTime and maxTime Option was only available in the new version  
      Thats the Part of the JS that is not working correctly:
      if(datetimerules && datetimerules.length){ options.onSelect = function(date, inst) { var day = $(this).datetimepicker("getDate").getDay(); day = day.toString(); var mintime = $(this).attr('data-weekday'+day+'-mintime'); var maxtime = $(this).attr('data-weekday'+day+'-maxtime'); console.log("weekday: "+day); console.log("minTime: "+mintime); console.log("maxTime: "+maxtime); var optionsAll = $(this).datetimepicker( "option", "all" ); optionsAll.minTime = mintime; optionsAll.maxTime = maxtime; $(this).datetimepicker('destroy'); $(this).datetimepicker(optionsAll); $(this).datetimepicker('refresh'); //$.datepicker._selectDate($(this).attr("id"),date); //$.datepicker._base_getDateDatepicker(); // var inst = $.datepicker._getInst($(this)); // $.datepicker._updateDatepicker(inst); /*$(this).datetimepicker('destroy'); InputfieldDatetimeDatepicker($(this), mintime, maxtime); $(this).datetimepicker('refresh'); */ // $(this).datetimepicker('option', {minTime: mintime, maxTime: maxtime}); } } Can you have a look and find out what the Problem is?
      InputfieldDatetime.zip
       
      Kind Regards
      Orkun
×
×
  • Create New...