Jump to content

Tracy Debugger


adrian

Recommended Posts

4 minutes ago, gmclelland said:

The scanning of files for ToDo items to prevent any file scanning altogether.

I remember Drupal having a similar problem here https://www.drupal.org/node/2329453

But that's what the "Ignore Directories" option is for. Are you suggesting that I should hard code in  those bower, sass, node_modules etc, so you don't need to manually add them?

Link to comment
Share on other sites

No, I'm not suggesting you hard code those values.  I just thought those "node_modules, .sass-cache, etc.." could be added to the other defaults (git svn etc..).

I was also suggesting to include a new checkbox [Scan files for To Do items].  Checking this would show all the other fields(like defaults to exclude, scan modules? etc..).  This way the whole functionality can be turned off completely if it isn't going to be used.

No biggie though, as of right now I'm not experiencing any performance problems.

Link to comment
Share on other sites

2 minutes ago, gmclelland said:

I just thought those "node_modules, .sass-cache, etc.." could be added to the other defaults (git svn etc..).

Ok, that sounds reasonable :)

2 minutes ago, gmclelland said:

I was also suggesting to include a new checkbox [Scan files for To Do items].  Checking this would show all the other fields(like defaults to exclude, scan modules? etc..).  This way the whole functionality can be turned off completely if it isn't going to be used.

Scanning will only happen if you have the ToDo panel enabled - disabling the panel would do the same as what you are suggesting, unless I am not fully understanding ?

Link to comment
Share on other sites

30 minutes ago, adrian said:

Scanning will only happen if you have the ToDo panel enabled - disabling the panel would do the same as what you are suggesting, unless I am not fully understanding ?

Great.  I didn't know that.  I'll just turn off that panel.  Thanks Adrian

  • Like 1
Link to comment
Share on other sites

@gmclelland - latest version includes node_modules and sass-cache as default directories to exclude.

On an unrelated note, I have also added a new "Selector Queries" section to the PW Debug panel. This shows you all the selector calls made during the current page load.

58c7393ae0543_ScreenShot2017-03-13at5_26_18PM.thumb.png.c1f30ec94a67566155c5d21a4340249e.png

 

This post also includes a Console Panel snippet idea. If you need to look up a page, template or field ID, this snippet will return the name, title, label, edit and view links, etc. Just enter the ID and the type and run. I have saved it as "Info from ID", but you can choose whatever name you want. Code included in a spoiler below. 

58c73a072d2c5_ScreenShot2017-03-13at5_31_41PM.thumb.png.d4c21bf31601206cea879cb8a2496824.png

Spoiler

$id = 1; // ID of page, template or field
$type = 'page'; // 'page', 'template', or 'field'

// no need to edit below
$typeVar = $type.'s';
$obj = $$typeVar->get($id);
if($obj->id) {
    if($type == 'page') {
        echo '<p><strong>' . $obj->title . '</strong></p><p>' .
        ($obj->editable() ? '<a href="'.$obj->editUrl().'">Edit</a>' : 'Page not editable.') . ' | ' . 
        ($obj->viewable() ? '<a href="'.$obj->url.'">View</a>' : 'Page not viewable') . '</p><p>' .
        'Path: ' . $obj->path . '<br />' .
        'URL: ' . $obj->httpUrl . '<br />' .
        'Template: ' . $obj->template->name .
        '</p>';
    }
    if($type == 'template') {
        echo '<p><strong>' . ($obj->label ? $obj->label.' ('.$obj->name.')' : $obj->name) . '</strong></p><p>' .
        '<a href="'.$config->urls->admin.'setup/template/edit?id='.$id.'">Edit</a>' .
        '</p>';     
    }
    if($type == 'field') {
        echo '<p><strong>' . ($obj->label ? $obj->label.' ('.$obj->name.')' : $obj->name) . '</strong></p><p>' .
        '<a href="'.$config->urls->admin.'setup/field/edit?id='.$id.'">Edit</a>' .
        '</p>';     
    }    
}
else {
    echo '<p>' . ucfirst($type) . ' does not exist.</p>';
}

 

 

  • Like 5
Link to comment
Share on other sites

Hey @adrian and others, I need your help. How can I use the Tracy Debug Bar on an external site, which includes ProcessWire´s core?

Tracy is already defined when I include the ProcessWire core (where Tracy Debugger is installed), so I don´t include the standalone version of Tracy anymore.
But the debug bar does not show up nor the needed HTML code gets added to the page.

Here is what I do. How can I show this beautiful debug thingy?

This does not work:
require(__DIR__ . '/../myprocesswire-installation/index.php');
TD::barDump('Show a dump'); // This does nothing

// This works if I don´t include ProcessWire, but I need it
//require 'lib/tracy/src/tracy.php';
//    use Tracy\Debugger;
//
//    Debugger::enable();
//    Debugger::$logSeverity = E_NOTICE | E_WARNING;
//    Debugger::barDump('test');

 

Link to comment
Share on other sites

@jmartsch - I think the issue you are having is likely permission access to the debug bar. When I use it in bootstrapped mode, I can use bd() calls as normal. Just make sure you are logged into the backend before loading the bootstrapped page.

Does that work for you?

PS - I don't have to do any manual loading of the Tracy core when I do this.

Link to comment
Share on other sites

Glad that worked for you @jmartsch

On another note, the new Selector Queries section in the DebugMode panel now includes a "Time" column so you can see how long each of your selectors is taking. Note that #7 is an intentionally relatively slow query to make a point for this screenshot:

58cad015e6879_ScreenShot2017-03-16at10_48_18AM.png.cd08a59d7d8da7c04c6c1387282b4439.png

Keep in mind that caching may get involved here once you reload a page. Clearing the session (eg logging out and in again) will show you the speed on first load for a user.

Also, just added a "Logout" icon/button to the PW Info panel - nice shortcut if you want to logout from the front-end of your site.

58cad309933ec_ScreenShot2017-03-16at11_01_31AM.png.cb24378b42ade23c36e493a4c91afc8a.png

  • Like 2
Link to comment
Share on other sites

For anyone who tries out the new sidebar features in the UiKit admin theme, I just wanted to mention that I already have a partial fix (not committed yet) for the problem of the debug bar appearing in each sidebar, along with the main content area. Each sidebar (and main content area) is an iframe, which is why the debug bar gets loaded in each one. The fix I have works for the initial page load, but falls down when you try to edit a page. I have suggested a change to the core/uikit theme to Ryan (in a PM) that will allow me to fix this as well, but I need him to implement first.

I'll update Tracy as soon as there is a fully working solution.

Cheers,
Adrian

  • Like 1
Link to comment
Share on other sites

Ok, I went with a different fix for the UiKit admin theme sidebars that works with the current version of PW and the UiKit theme.

If sidebars are enabled, the Tracy debug bar is attached to the main iframe. 

Please let me know if you notice any issues.

Link to comment
Share on other sites

Hi @adrian,

I didn't read the whole 37 sites, so sorry if this comes up again, but I have a really weird problem: The debugger bar is not shown in one situation. Most of the time it will not show if I do something like this:

  1. fill out formular and send (bar is shown before send)
  2. check form (same page/template), if ok: forward to another page.
  3. at the other page: the bar is not loaded/shown, even after reload and browser cache disabled.
  4. waiting for around one or two minutes, then reload the same page: bar is shown.

Between point 3 and 4 I can visit other pages and the bar is still not shown. At point 4 the missed dumps and send emails are shown. This is making problems at some pages, that should not be reloaded again.

After some minutes the bar is shown again. before there is no visibility, and the div container with the id "tracy-debug" is not loaded/created. The show button is loaded, but hidden and if unhidden then it has no function at all.

Is this known?

Link to comment
Share on other sites

Hi @godmok - thanks for the report. Unfortunately I am having a trouble understanding exactly what the steps are to reproduce this. Is there any chance you could share a screencast of the problem in action? Also, might I have access to the server (if it's online) so I can test - although I think the screencast first still might be important.

I don't think I have ever come across anything like this. Anyone else ?

Hopefully we can get to the bottom of it though and get it fixed.

 

  • Like 1
Link to comment
Share on other sites

Just added a new "Clear Session & Cookies" button in the ProcessWire Info panel:

58d86d8704d75_ScreenShot2017-03-26at6_40_10PM.png.842698bfd19eddc5601a50496ec018df.png

It's the new reset/reload looking icon.

This will log you out and back in again, clear all cookies for the domain, and return you to the same URL you were on (along with the full query string).

I have been finding this very handy with module development when it is manipulating parts of the admin that are cached (like menus etc), but it can also be handy for example when you change an Images field's "Default image grid mode" setting because you need to clear cookies to see these changes. I am sure you'll find other uses as well.

  • Like 4
Link to comment
Share on other sites

On 6/19/2016 at 8:04 AM, netcarver said:

@adrian, Git branch integration next? :rolleyes:

Well, it's been a long time coming, and not sure if it's exactly what you had in mind, but I just added a new "Git Info" panel that displays Git branch, latest commit message, etc for your site (assuming you have it under Git version control). This is just the first version. My goal is to add color coding of the icon (like many other panels) to get your attention. I am looking for feedback on this though. I could either make it possible to configure different colors for different branches, or else I could try to match the branch name against the subdomain / extension, eg. dev.mysite.com, staging.mysite.com or mysite.dev, mysite.staging, etc and color green if they match and red as a warning if they don't.

Anyone have any thoughts on the best approach?

58dc0851b7439_ScreenShot2017-03-29at12_11_10PM.png.56daffa26d97781985903d582bc77898.png

 

On another note, I just had to do quite a bit of work fixing the "Versions List" feature on the ProcessWire Info panel - two recent Tracy core updates broke this functionality and I just noticed. Also, it looks like Github changed the way they handle line breaks inside <details> tags, so also had to tweak that, but I think everything is working again now!

  • Like 3
Link to comment
Share on other sites

Hi @Ivan Gretsky - you need to manually set the output mode to "DEVELOPMENT" to make the User Switcher work. I initially set it up this way as an additional security layer, but I am thinking about revising the need to do this.

Let me know if you still have any problems.

  • Like 2
Link to comment
Share on other sites

Just now, Ivan Gretsky said:

Are there any string reasons why not allow it for DETECT mode?

I was trying to be extra cautious just in case someone could spoof DETECT mode, although I don't really think that is an issue - I will revisit this sometime soon, because it would be nice if this was always available.

2 minutes ago, Ivan Gretsky said:

Does it allow to switch to default guest user somehow?

Use the "Logout" button - that will log you out so you are a "guest", but still keep the Tracy debug bar available and keep the User Switcher session alive.

Feel free to post any suggestions for improvements as you play around with this.

  • Like 2
Link to comment
Share on other sites

1 minute ago, Ivan Gretsky said:

There is no one-click way to log in again, is it?

Of course - just choose a different user and click "Switch".

Don't forget to set a session length before initially clicking Logout though so that the User Switcher is activated in the first place.

Sorry if it's not totally intuitive - I haven't had much feedback on this feature yet.

Link to comment
Share on other sites

@M.O.Z.G - I think you must be running the Legacy version of the Tracy core? Do you have PHP 5.4+ so you can run the Master version?

That said, I still don't know why all those "previous" bars are staying like that. Do they go away if you clear the PW session (log out and back in again)? Does the problem continue after that? When did this start happening for you - was it a PW or Tracy upgrade, or a move to a new server? Any unusual session settings on the server?

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