Jump to content
adrian

Tracy Debugger

Recommended Posts

Hey Adrian,

--- SOLVED ---

I have this code that returns an unexpected result. I don't know if that's related to tracy, so I apologize if it is not...

I'm developing a module. $rc->step is a shopping cart step object and it is possible to attach forms to it. $step->forms is a WireArray. I add the form "test" to this WireArray but when I dump it, it shows just the name of the Form, whereas when I dump the single item via $step->forms->first() I get what I expect (an InputfieldForm object).

9weZNcW.png

On the "Full Object" tab the output is also as I'd expect it to be:

ejST8VO.png

I guess that's totally normal but I'd like to understand what's going on and why the form shows up as string in the Debug Info Tab, thx!

Edit: Ok sorry for this post, but it might also be interesting for somebody else. The debuginfo returns the id or classname of any WireData objects: https://github.com/processwire/processwire/blob/master/wire/core/WireArray.php#L2442-L2446

  • Like 2

Share this post


Link to post
Share on other sites

Hey @bernhard - glad you figured it out.

The one thing I would like to know more about is that errant padding at the bottom of the tab labels/links. Could you please figure out what css rule on your site is adding that padding so I can adjust Tracy's CSS so there is no conflict?

Thanks.

Share this post


Link to post
Share on other sites

@kongondo and everyone else 🙂

I have just added caching for both the Tracy and PW logs panels so now they only read a log file if it has changed since it was last cached. This should make a dramatic difference to most page loads.

Do note that if you have a large log file and a new entry is added, then the load time will still be slow for that first page load when the entry is logged, so you still may want to delete log files (or use the PW log prune function) if you notice a slow load.

Hope that helps everyone.

  • Like 6

Share this post


Link to post
Share on other sites

Just committed some improvements to the log panel caching and also added caching for the ToDo panel which is a HUGE improvement - this has gone from 1.5 seconds to 60ms in my tests.

  • Like 4
  • Thanks 1

Share this post


Link to post
Share on other sites

Yes, I experience the same as @kongondo.

PW logs are running fast, but as soon as I enable Tracy Log, its getting slow. Here is a screenshot

image.png.2c1d924f95c5271ee1a15c04e6912ce6.png

And I think I know why it takes so long. Look at this. 1,48 GB WTF?

image.thumb.png.7aa40a03389e68dcf1614c879bf26779.png

Share this post


Link to post
Share on other sites
1 hour ago, jmartsch said:

And I think I know why it takes so long. Look at this. 1,48 GB WTF?

Yeah, that'll do it 🙂

I am curious though - with the caching now in effect, doesn't it load quickly now? If not, then I expect there is an error that is being logged on every page load (meaning that the cache needs to be updated on each page load).

What errors are being logged?

Share this post


Link to post
Share on other sites

Thanks to ideas and feedback from @tpr, the File Editor panel now has a recently opened files selector which shows the last 10 files you opened - much quicker if you need to navigate back and forwards between several different files.

image.png.6cf84acf68baf77f3bbf3a4cc508eb50.png

 

There is also a new config setting which lets you exclude folders. Previously for performance it was best to limit the Base Directory setting to "Templates", rather than "Site" or "Root", but now you can select an higher level and exclude what you don't need. Most users will probably want to select "Site" and exclude "site/assets" and "site/modules" - this lets you access site/templates, as well as config.php, init.php. ready.php, & finished.php - you get the idea.

I also made some other speed improvements by excluding completely any directories with files that are not editable, so the payload for this panel is now much smaller.

Hope this helps you out when an online editor is the only option you have.

Don't forget the fullscreen toggle at the top left of the editor, or the normal "Maximize" toggle at the top right of the panel - makes life much nicer!

image.png.850ded00e50fed8b7d228ec4b13f4ae7.png

 

 

  • Like 4
  • Thanks 1

Share this post


Link to post
Share on other sites

This is all @tpr's hard work - he has just added a search/filter implementation using his awesome filterbox.js - be sure to check it out and Star it!

Note that in addition to filtering, if you hit "Enter" it will load the first matched file.

Thanks again Roland - this is very cool!

C88CqYappr.gif.abd0deaaa94bcb80b37b4042a468fa5b.gif

  • Like 6

Share this post


Link to post
Share on other sites

Thanks @adrian, I was really missing these features (search and recents list). It was a challenge to set up FilterBox to fit in here but fortunately everything fell into place.

  • Like 3

Share this post


Link to post
Share on other sites

Hi Adrian,

Now that "live" is used as the default dump method there's an item in the shortcut methods description that should be deleted:

2019-03-18_114723.png.d4e6763a922165e38c2c6df2362b55b1.png

And maybe in the docs too? https://adrianbj.github.io/TracyDebugger/#/debug-methods?id=bardumplive
Or maybe move the explanation of live dumping to the intro of this section.

Also, I'm trying to get my head around how this live dump works. Are you able to point me to a page in the Nette docs that covers this feature? I've been looking but haven't been able to find it.

And if the dump data is loaded in realtime as the levels are expanded then how come there is truncation in the example shown below?

 2019-03-18_115743.png.875dba621efa7890920b4cd4b708abf0.png

Thanks.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for spotting the left over LIVE reference.

Actually between 2.6 dev and the releases version of 2.6 of the Tracy core, they actually changed LIVE to LAZY. LIVE still exists as a separate option but it still has some downsides. In most cases LAZY is better. You can read more about it here: https://github.com/nette/tracy/issues/344#issuecomment-468123490

Your data is still truncated because of the default maxDepth of 3 which is tweakable in the module settings. With lazy it's possible to have a much greater depth without performance issues so maybe I will up that at some point. You can of course still use db() or bdb() or bd($var, [10]) or one of the other combinations to up the depth. You'll find that with the new LAZY approach you can actually do a bd($page, [10]) and it won't cause an out of memory error like it would with Tracy 2.5. Hope that helps. If you have any more technical questions let me know, or perhaps address them to @dg at Nette.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for the info. From the discussion you linked to it sounds like the LIVE/LAZY features are still a work-in-progress and subject to change. So will wait a while before I delve into it.

The thing that was confusing me was that the previous barDumpLive() didn't take any $options argument for maxDepth or maxLength which made me think there is no limit for these when a live dump is used. But no problem to keep using bdb() for larger dumps.

  • Like 2

Share this post


Link to post
Share on other sites

Perhaps I was too hasty in removing the live option, so maybe it will make a comeback now that LAZY is the default - just need some more testing to see if it actually helps with large dumps, and whether there are issues with the integrity of the data.

So far from what I can tell, LAZY does an awesome job even with: 

bd($page, array('maxDepth' => 99));

or the shortcut:

bd($page, [99]);

 

  • Like 2

Share this post


Link to post
Share on other sites

Hi everyone.

Lots of new stuff this morning.

1) Terminal panel (available in a panel and also as a dedicated Process module - similar to how the Adminer feature is set up)

NOTE: It does not support interactive commands like vi, nano, apt, etc. DO NOT attempt to use these as they may result in you needing to restart apache.

This is a bash terminal that lets you quickly execute commands on a server. In addition to normal commands like: ls, cd, cat, mkdir, rm, chmod, chown, etc, you can also do mysql command line calls which is very handy if you need to add a new user, create a mysqldump etc.

Note that for mysql commands you need to issue them individually - you can't simply start "mysql" and issue commands from there - each call needs to include your username and password and the command to be run, eg:

mysql -u root -p mypassword -e "CREATE DATABASE newtablename";

There is also an upload and download command, eg "upload test.txt" which will spawn a file selector dialog on your machine to upload that file to your server with the given name. It also has arrow up and down for command history as well as tab autocompletion of commands and file names.

VS3HkyE49n.thumb.gif.f1c9be0f29a626eef431a3c5c5225f24.gif


2) Lots of new filterbox implementations

@tpr has again put in lots of work to implement filterbox on the APIExplorer, Captain Hook, and PHPInfo panels - these will be super helpful to search through these complex panels.

I have also added a ALT+F shortcut to get your cursor into the Find input for all these panels.

KwpdpHeWLI.thumb.gif.472bea94a8b5ecc97fe53222f801f95b.gif


Let us know how these new features work out for you.

Cheers!

 

  • Like 11

Share this post


Link to post
Share on other sites

Nice! Is terminal supported on windows? Don't have time to play right now, I just tried dir 🙂

 

 

Screenshot 2019-03-18 21.04.05_cr.jpg

Share this post


Link to post
Share on other sites
19 minutes ago, matjazp said:

Nice! Is terminal supported on windows? Don't have time to play right now, I just tried dir 🙂

I had @tpr take a quick look and it sounded like it worked, but I don't think he tested thoroughly. Maybe @bernhard would be willing to have a look as well.

I know it works well on Mac and Linux.

Share this post


Link to post
Share on other sites

o6HTusV.png

It seems to be working, but in panel mode it's not really usable... The problem also occurs on the ProcessModule's page when I have more content than available screen space. I tried it on linux and it seems to have similar effects (eg when hitting TAB to list available directories on cd foo/bar/...

But I'm not keen on this new feature. When I need a terminal, then well... I open one. Most of the time from within my IDE via ssh. I don't see a benefit of using it via tracy - but maybe that's because I don't really like working in the terminal in general 🙂 

And I'm a little worried about security aspects... even if I don't have any idea how all that new console feature works. Just saying that if I don't need this feature I'm not really happy to have it there. I uninstalled the process module, but still... the code is somewhere on the server. Maybe you can tell us a bit to make me feel more comfortable 🙂 

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for testing @bernhard - I'll see if I can duplicate the issues you are seeing with layout - it seems fine here, but I'll test some more and see if I can try on a Windows machine.

I agree that I would mostly choose a real terminal over this, but if I don't know the credentials for the server (or I am away from my computer), this is a pretty good backup, which is the way I view this feature.

Regarding security - I thought through this already and here's my reasons why it's not an issue:

1) The file is not available outside the process module - PW's htaccess restrictions ensure that.

2) The process module requires superuser permission.

3) It's no more dangerous than the Console panel or Hanna code - both let you run shell_exec commands on the server anyway. This just provides a nicer interface and returns the output for you.

That said, if anyone can think of a security concern that I have overlooked, please let me know.

  • Like 1

Share this post


Link to post
Share on other sites

@tpr has yet again put in lots of time to improve the filtering for the APIExplorer and Captain Hook panels:

PDkwvpi1Hz.thumb.gif.373d9fef08cbc6601a5f7fb885e3c680.gif

  • Like 3

Share this post


Link to post
Share on other sites
6 hours ago, bernhard said:

The problem also occurs on the ProcessModule's page when I have more content than available screen space. I tried it on linux and it seems to have similar effects (eg when hitting TAB to list available directories on cd foo/bar/...

Can you explain this a little more please. I just tested on a Windows machine (although pointed to a linux server), but I can't see any issues. Could you maybe put together a screencast for me demonstrating the issue? Thanks!

  • 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 Robin S
      A community member raised a question and I thought a new sanitizer method for the purpose would be useful, hence...
      Sanitizer Transliterate
      Adds a transliterate method to $sanitizer that performs character replacements as defined in the module config. The default character replacements are based on the defaults from InputfieldPageName, but with uppercase characters included too.
      Usage
      Install the Sanitizer Transliterate module.
      Customise the character replacements in the module config as needed.
      Use the sanitizer on strings like so:
      $transliterated_string = $sanitizer->transliterate($string);
       
      https://github.com/Toutouwai/SanitizerTransliterate
      https://modules.processwire.com/modules/sanitizer-transliterate/
       
    • By dimitrios
      Hello,
      this module can publish content of a Processwire page on a Facebook page, triggered by saving the Processwire page.
      To set it up, configure the module with a Facebook app ID, secret and a Page ID. Following is additional configuration on Facebook for developers:
      Minimum Required Facebook App configuration:
      on Settings -> Basics, provide the App Domains, provide the Site URL, on Settings -> Advanced, set the API version to 2.10, add Product: Facebook Login, on Facebook Login -> Settings, set Client OAuth Login: Yes, set Web OAuth Login: Yes, set Enforce HTTPS: Yes, add "http://www.example.com/processwire/page/" to field Valid OAuth Redirect URIs. This module is configurable as follows:
      Templates: posts can take place only for pages with the defined templates. On/Off switch: specify a checkbox field that will not allow the post if checked. Specify a message and/or an image for the post.
      Usage
      edit the desired PW page and save; it will post right after the initial Facebook log in and permission granting. After that, an access token is kept.
       
      Download
      PW module directory: http://modules.processwire.com/modules/auto-fb-post/ Github: https://github.com/kastrind/AutoFbPost   Note: Facebook SDK for PHP is utilized.


    • By thomasaull
      I created a little helper module to trigger a CI pipeline when your website has been changed. It's quite simple and works like this: As soon as you save a page the module sets a Boolean via a pages save after hook. Once a day via LazyCron the module checks if the Boolean is set and sends a POST Request to a configurable Webhook URL.
      Some ideas to extend this:
      make request type configurable (GET, POST) make the module trigger at a specified time (probably only possible with a server cronjob) trigger manually Anything else? If there's interest, I might put in some more functionality. Let me know what you're interested in. Until then, maybe it is useful for a couple of people 🙂
      Github Repo: https://github.com/thomasaull/CiTrigger
    • By Robin S
      I created this module a while ago and never got around to publicising it, but it has been outed in the latest PW Weekly so here goes the support thread...
      Unique Image Variations
      Ensures that all ImageSizer options and focus settings affect image variation filenames.

      Background
      When using methods that produce image variations such as Pageimage::size(), ProcessWire includes some of the ImageSizer settings (height, width, cropping location, etc) in the variation filename. This is useful so that if you change these settings in your size() call a new variation is generated and you see this variation on the front-end.
      However, ProcessWire does not include several of the other ImageSizer settings in the variation filename:
      upscaling cropping, when set to false or a blank string interlace sharpening quality hidpi quality focus (whether any saved focus area for an image should affect cropping) focus data (the top/left/zoom data for the focus area) This means that if you change any of these settings, either in $config->imageSizerOptions or in an $options array passed to a method like size(), and you already have variations at the requested size/crop, then ProcessWire will not create new variations and will continue to serve the old variations. In other words you won't see the effect of your changed ImageSizer options on the front-end until you delete the old variations.
      Features
      The Unique Image Variations module ensures that any changes to ImageSizer options and any changes to the focus area made in Page Edit are reflected in the variation filename, so new variations will always be generated and displayed on the front-end.
      Installation
      Install the Unique Image Variations module.
      In the module config, set the ImageSizer options that you want to include in image variation filenames.
      Warnings
      Installing the module (and keeping one or more of the options selected in the module config) will cause all existing image variations to be regenerated the next time they are requested. If you have an existing website with a large number of images you may not want the performance impact of that. The module is perhaps best suited to new sites where image variations have not yet been generated.
      Similarly, if you change the module config settings on an existing site then all image variations will be regenerated the next time they are requested.
      If you think you might want to change an ImageSizer option in the future (I'm thinking here primarily of options such as interlace that are typically set in $config->imageSizerOptions) and would not want that change to cause existing image variations to be regenerated then best to not include that option in the module config after you first install the module.
       
      https://github.com/Toutouwai/UniqueImageVariations
      https://modules.processwire.com/modules/unique-image-variations/
    • By Sebi
      I've created a small module which lets you define a timestamp after which a page should be accessible. In addition you can define a timestamp when the release should end and the page should not be accessable any more.
      ProcessWire-Module: http://modules.processwire.com/modules/page-access-releasetime/
      Github: https://github.com/Sebiworld/PageAccessReleasetime
      Usage
      PageAccessReleasetime can be installed like every other module in ProcessWire. Check the following guide for detailed information: How-To Install or Uninstall Modules
      After that, you will find checkboxes for activating the releasetime-fields at the settings-tab of each page. You don't need to add the fields to your templates manually.
      Check e.g. the checkbox "Activate Releasetime from?" and fill in a date in the future. The page will not be accessable for your users until the given date is reached.
      If you have $config->pagefileSecure = true, the module will protect files of unreleased pages as well.
      How it works
      This module hooks into Page::viewable to prevent users to access unreleased pages:
      public function hookPageViewable($event) { $page = $event->object; $viewable = $event->return; if($viewable){ // If the page would be viewable, additionally check Releasetime and User-Permission $viewable = $this->canUserSee($page); } $event->return = $viewable; } To prevent access to the files of unreleased pages, we hook into Page::isPublic and ProcessPageView::sendFile.
      public function hookPageIsPublic($e) { $page = $e->object; if($e->return && $this->isReleaseTimeSet($page)) { $e->return = false; } } The site/assets/files/ directory of pages, which isPublic() returns false, will get a '-' as prefix. This indicates ProcessWire (with activated $config->pagefileSecure) to check the file's permissions via PHP before delivering it to the client.
      The check wether a not-public file should be accessable happens in ProcessPageView::sendFile. We throw an 404 Exception if the current user must not see the file.
      public function hookProcessPageViewSendFile($e) { $page = $e->arguments[0]; if(!$this->canUserSee($page)) { throw new Wire404Exception('File not found'); } } Additionally we hook into ProcessPageEdit::buildForm to add the PageAccessReleasetime fields to each page and move them to the settings tab.
      Limitations
      In the current version, releasetime-protected pages will appear in wire('pages')->find() queries. If you want to display a list of pages, where pages could be releasetime-protected, you should double-check with $page->viewable() wether the page can be accessed. $page->viewable() returns false, if the page is not released yet.
      If you have an idea how unreleased pages can be filtered out of ProcessWire selector queries, feel free to write an issue, comment or make a pull request!
×
×
  • Create New...