Jump to content

Tracy Debugger


adrian

Recommended Posts

"PW's debug mode doesn't really change error reporting anymore". Can you please explain it a bit more? I do not quite get this.
 
About "superuser only mode": the module should also support non-superuser debugging too. What happens when we want to debug while logged in as another user+role? Why should we miss Tracy in this case? :) The more control we have in this area is the better, I suppose.

Debug mode in PW does two main things - it allows PHP errors/warnings to be displayed, and it shows the Debug Mode Tools in the admin. With Tracy enabled, you get the errors/warnings, whether Debug Mode is on or off, so I am finding that I no longer need it on, and it also means that I can debug a live site easily without anyone seeing the errors and $variable testing output.

I agree - we need to be able to use Tracy for non-superusers - just trying to figure out the most logical way. I feel like maybe it should simply be based on the PW Debug Mode setting and a dedicated "tracy-debugger" role. So if debug mode is off, then Tracy is only for superusers, but if debug mode is on, then non-superusers with the tracy-debugger role will have full access. This way you can create a test user with the required role and simply add the tracy-debugger role to their details and things will work. Does anyone have any thoughts on this? 

I should have checked "my" css before asking this question, sorry for this. I use a "framework" called Responsee 3 which happens to change the display property of <img> to "block". Changing it back to "inline" or "inline-block" fixes is the issue.

I do not know if you want deal with this issue or not, but you might be able to address this by targeting Tracy's <img> tags to set "inline" or "inline-block" !important on them, just in case... As far as I can see, Tracy itself uses a lot of !important rules as well. Maybe the developers of Tracy should apply this, and it is out of the scope of your module.

EDIT: "inline" or "inline-block"

I have replaced all icons with inline SVG - that should deal with your issue - please let me know if it looks ok now.

  • Like 1
Link to comment
Share on other sites

Debug mode in PW does two main things - it allows PHP errors/warnings to be displayed, and it shows the Debug Mode Tools in the admin. With Tracy enabled, you get the errors/warnings, whether Debug Mode is on or off, so I am finding that I no longer need it on, and it also means that I can debug a live site easily without anyone seeing the errors and $variable testing output.

Thank you for explaining it!

I agree - we need to be able to use Tracy for non-superusers - just trying to figure out the most logical way. I feel like maybe it should simply be based on the PW Debug Mode setting and a dedicated "tracy-debugger" role. So if debug mode is off, then Tracy is only for superusers, but if debug mode is on, then non-superusers with the tracy-debugger role will have full access. This way you can create a test user with the required role and simply add the tracy-debugger role to their details and things will work. Does anyone have any thoughts on this? 

Tying it to to ProcessWire's debug mode in this way does not seem to be the best idea if they can actually be independent. Why don't you just introduce another option in the settings to indicate that non-superusers with the tracy-debugger role have full access too? BTW, I like the idea of "tracy-debugger role". The only useful case of utilizing the state of the debug mode seems to be when with Tracy enabled, we get errors/warnings in the case of any non-superusers too, so that it works in a similar way as the debug mode does, which might be expected in the first place. By turning debug mode off, only superuser and/or "tracy-debugger role" users have access to Tracy.

I have replaced all icons with inline SVG - that should deal with your issue - please let me know if it looks ok now.

Thanx again, it has solved the issue!

  • Like 1
Link to comment
Share on other sites

Ok, I have now added the ability to enable Tracy for non-superusers. Users with a role that has the "tracy-debugger" permission will have access. I would recommend created a dedicated "tracy-debugger" role with just the "tracy-debugger" permission. That way you can easily give a user the required permission without giving any other users access. 

There is also a new "Allowed Non-Superusers" panel that warns you that you have given some non-superusers permission to view Tracy and lists the users and roles affected.

post-985-0-72536100-1455837898_thumb.png

post-985-0-72411800-1455837899_thumb.png

For the moment I have decided not to allow everyone access when the PW debug mode is on. I see the logic in this, but Tracy provides a lot more information than what the debug mode does, so I am hesitant to enable anyone to see that information without specifically being given the appropriate permission.

Please let me know what you guys think of the current version. If there are no issues, I will release this to the modules directory tomorrow.

Thanks again for all the testing and feedback!

  • Like 1
Link to comment
Share on other sites

Sorry haven't had time to test yet; please clarify...apart from the 1 issue you mentioned a couple of posts up, this should work just fine in PW 2.7.x? Thanks.

Thanks for the prompting. The latest version should now work with the 2.7.x branch, but please let me know if you find any problems.

  • Like 3
Link to comment
Share on other sites

Latest version has two new features:

Performance panel

Shows memory usage and execution time between breakpoints.

You add breakpoints using one of these:

TD:addBreakpoint('Breakpoint Name');
addBreakpoint('Breakpoint Name');
bp('Breakpoint Name');

post-985-0-39542400-1455906548_thumb.png

PW Logs viewer panel

This shows the last 4 entries for the PW errors, exceptions, messages, warnings logs. This is just meant to give you a quick look at the last few entries without needing to go to the PW admin to the Setup>Logs section

post-985-0-23089400-1455906832_thumb.png

  • Like 5
Link to comment
Share on other sites

Ok, it's now live in the modules directory: http://modules.processwire.com/modules/tracy-debugger/

Thanks everyone for the feedback thus far, but please keep it coming - I am sure you will have suggestions on how it can be improved!

I would also like to add additional 3rd party panels as requested, so take a look here (https://addons.nette.org/#toc-debug-bar-panels) for some possible things you may be interested in. Keep in mind, that link isn't properly scrolling down, so click on the "DebugBar panels" under Categories on the right.

  • Like 2
Link to comment
Share on other sites

Thank you adrian!
First I deleted a previous version of the module manually, afterwards installed it via the modules directory. Now I get this (both public frontend and admin):

1× PHP Notice: A session had already been started - ignoring session_start() in .../site/modules/TracyDebugger/tracy/src/Tracy/Bar.php:59

Is it because I did not know how to upgrade properly or something else?
 

Link to comment
Share on other sites

Thank you adrian!

First I deleted a previous version of the module manually, afterwards installed it via the modules directory. Now I get this (both public frontend and admin):

1× PHP Notice: A session had already been started - ignoring session_start() in .../site/modules/TracyDebugger/tracy/src/Tracy/Bar.php:59

Is it because I did not know how to upgrade properly or something else?

@szabesz - sorry about that. I am guessing that you have the Force Scream mode checked? There is what I consider a bug in Tracy: https://forum.nette.org/en/25569-strict-and-scream-modes-together - I don't think that Force Scream should show warnings/notices from the Tracy core.

Initially I modified the Tracy core to handle this better, but it turned out not to work in some server configs, so I went back to using the @ to suppress the session_start error. 

Anyway, I think if you save the config settings page for this module again it should get things working - I now prevent Strict and Force Scream modes from being abled at the same time. Please let me know if that works for you. 

  • Like 1
Link to comment
Share on other sites

Anyway, I think if you save the config settings page for this module again it should get things working - I now prevent Strict and Force Scream modes from being abled at the same time. Please let me know if that works for you. 

"...it should get things working" What do you exactly mean by this? I saved the settings a few times, once with Strict Mode only enabled, then with Force Stream only on, but no matter what I do, this notice comes up when Force Stream is on (and Strict Mode is off). Should it be possible to use Force Stream without getting this notice or not?

My personal preference would be to be informed of notices and warnings (of ProcessWire and my code, not Tracy's). I do not need Strict Mode if that is not necessary to be able to see notices and warnings.

Sorry if it is a dumb question, but I do not quit get what the situation is. You wrote "...an issue with strict and scream modes together...", however, currently only Force Stream is on and the notice shows up as an error in the debug bar:

post-4029-0-92380100-1455983075_thumb.pn

Link to comment
Share on other sites

Thanks for that screenshot - that helps! What you are seeing there is because you have Force Scream mode enabled. I assumed you are getting the notice on the entire page blocking the site (like you get in Strict Mode). 

In reality I don't think you should have Force Scream enabled by default - its only purpose is to show notices/warnings that are suppressed by PHP's @ shutup operator. This can be useful when debugging your code in certain circumstances, but if you are using @ then you are intentionally silencing these errors. I don't think they are typically a good practice, but there can be times when they can be considered acceptable.

Anyway, you can disable both Strict and Force Scream modes and you will still get notification of notices and warnings in Tracy. Try these in one of your template files to test:

trigger_error("Warning TEST", E_USER_WARNING);
trigger_error("Notice TEST", E_USER_NOTICE);

With Strict mode ENABLED they will be a full screen error, that you can skip using the "skip error" when you hover over the "Warning Test":

post-985-0-70444600-1455984352_thumb.png

But with Strict mode DISABLED, it will be in the Debugger bar:

post-985-0-31387100-1455984419_thumb.png

Does that make sense and allow you to work how you want?

PS Since I have that screenshot showing the "Skip Error" option, also note the "Search" option which links to a Google search of the issued error - a nice little shortcut :)

  • Like 1
Link to comment
Share on other sites

The latest version adds a new experimental "Variables" panel (thanks to a request by @matjazp).

This will show you the names and values of all non-ProcessWire variables available to the template of the current page - these are the variables you have defined in your template files and any "includes".

It is disabled by default so you need to turn it on in the config settings. It is only available for PW 3.x and currently only works on compiled templates (although I am looking to get it working on PW 2 / non-compiled templates). It also only works after a template file has changed for the first time after this module is installed/updated.

Please let me know if you have any problems with this feature - if you decide to enable it.

post-985-0-17339200-1456082840_thumb.png

This latest version also includes an enhanced PW panel - several additions/tweaks, but the most notable is the "Field Values" section which lists all Page fields and their values for the current page:

post-985-0-24655200-1456083617_thumb.png

  • Like 2
Link to comment
Share on other sites

firefox since, I forgot which version, is now built-in firefox developer tools, which do the same job as firebug extension.

Could it log to firefox developer tools?

I don't think there is any way to make this happen at the moment. At least I haven't been able to find a FireLogger browser plugin for Firefox that works with the default developer console. But maybe someone will develop one in the future. Given that there is one for the Chrome dev console, you'd think there would be one for Firefox.

Link to comment
Share on other sites

Thanks @adrian for the ProcessModuleToolkit link, I'll check that later but at first glance it's not entirely the thing I was after.

I see there are 6 'Show ...' panels next to each other in Tracy Debugger module settings, perhaps they could be shrinked under one section. I know it's a minor thing but could save a lot of space.

Link to comment
Share on other sites

I see there are 6 'Show ...' panels next to each other in Tracy Debugger module settings, perhaps they could be shrinked under one section. I know it's a minor thing but could save a lot of space.

Very good point - are you meaning one field of multiple checkboxes, or a collapsible fieldset of with all the options as they currently are?

I think the former would probably be quite nice, but it might be a pain for you guys when updating to a new version that has this because your current settings would be lost. I guess I could have some logic to convert the old separate checkboxes to the new multiple checkbox field, or maybe it doesn't really matter that much if you have to set them again?

I'll have a think.

Link to comment
Share on other sites

After upgrading to the latest version I get this error: Class 'ProcessWire\TracyDebugger' not found on the default PW install basic-page -template. What could cause this error?

file protected => "/Library/WebServer/Documents/pw3/site/assets/cache/FileCompiler/site/templates/basic-page.php"

Link to comment
Share on other sites

My idea was one field with multiple checkboxes. For me re-setting settings isn't a big deal. The first checkbox (frontend and backend) needs to be two separate checkboxes but I guess you've already noticed that :)

Link to comment
Share on other sites

After upgrading to the latest version I get this error: Class 'ProcessWire\TracyDebugger' not found on the default PW install basic-page -template. What could cause this error?

file protected => "/Library/WebServer/Documents/pw3/site/assets/cache/FileCompiler/site/templates/basic-page.php"

Hi @Ipa,

Sorry about this. To populate the new "Variables" panel I am adding a line to the bottom of the compiled template files, but it includes a check to see if the class exists so I am not sure why you are getting that. Could you please post what that last line looks like for you?

Link to comment
Share on other sites

The first checkbox (frontend and backend) needs to be two separate checkboxes but I guess you've already noticed that :)

Do you mean that it needs to stay as is and separate from the newly proposed multiple checkbox fields that lists checkboxes for all the panels, or do you think that it actually needs to be a separate checkbox field for frontend and another separate one for backend? Sorry, i am not seeing why they need to be separate ones, but it's early here, so maybe just not awake?

Nevermind, you just mean separate options within the one checkbox field, together with all the panels. Although I actually think it might still make sense to leave this as a separate field, because it is not related to panels - it's the entire Debug Bar. Hoped that sounds ok to you.

I guess I could also set it up so that you could choose which panels appear on the frontend and which ones appear on the backend - make them separately configurable, although not sure if that would really be that useful?

Link to comment
Share on other sites

Hi @Ipa,

Sorry about this. To populate the new "Variables" panel I am adding a line to the bottom of the compiled template files, but it includes a check to see if the class exists so I am not sure why you are getting that. Could you please post what that last line looks like for you?

It looks like this: 

<?php if(class_exists("TracyDebugger")) $this->wire("templateVars", TracyDebugger::templateVars(get_defined_vars(), \ProcessWire\wire("page")));

By the way, my Upgrades page tells me that I have version 0.5.0 installed and the latest is 0.4.9?

Link to comment
Share on other sites

Nevermind, you just mean separate options within the one checkbox field, together with all the panels. Although I actually think it might still make sense to leave this as a separate field, because it is not related to panels - it's the entire Debug Bar. Hoped that sounds ok to you.

Sure, either way is OK to me if you ask me :)

I also got that weird 0.5 update issue lpa mentioned.

Link to comment
Share on other sites

I also got that weird 0.5 update issue lpa mentioned.

Does it stick around? or is it gone once you reload the page or something? Can you post the last line of one of your template files that is producing the error?

Nevermind - sorry I see that @Ipa has already posted his.

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