Jump to content
adrian

Tracy Debugger

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

Share this post


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

Share this post


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

Share this post


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

  • Like 1

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

Thanks for the explanation, now I get it :) Yes, you are right, I suppose normally I (we) will not need Force Scream at all. I just misunderstood what it is for. I am also quite happy with Strict Mode turned off too.

  • Like 1

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

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 gebeer
      I am happy to present my new fieldtype FieldtypeImageFromPage. It is made up of 2 modules:
      Fieldtype Image Reference From Another Page is a Fieldtype that stores a reference to a single image from another page. The image can be selected with the associated Inputfield.
      Inputfield Select Image From Page is an Inputfield to select a single image from images on a predefined page and it's children.
      And there also is a helper module that takes care of cleanup tasks.
      This module evolved out of a discussion about my other Module FieldtypeImagePicker.  It caters for use cases where a set of images is being reused multiple times across a site. With this fieldtype these images can be administered through a chosen page. All images uploaded to that page will be available in the inputfield.
      When to use ?
      Let editors choose an image from a set of images that is being used site-wide. Ideal for images that are being re-used across the site.
      Suited for images that are used on multiple pages throughout the site (e.g. icons).
      Other than the native ProcessWire images field, the images here are not stored per page. Only references to images on another page are stored. This has several advantages:
      one central place to organize images when images change, you only have to update them in one place. All references will be updated, too. (Provided the name of the image that has changed stays the same) Features
      Images can be manipulated like native ProcessWire images (resizing, cropping etc.) Image names are fully searchable through the API Accidental image deletion is prevented. When you want to delete an image from one of the pages that hold your site-wide images, the module searches all pages that use that image. If any page contains a reference to the image you are trying to delete, deletion will be prevented. You will get an error message to help you edit those pages and remove references there before you can finally delete the image. How to install and setup
      Download and install this module like any other modules in ProcessWire Create a page in the page tree that will hold your images. This page's template must have an images field Upload some images to the page you created in step 2 Create a new field. As type choose 'Image Reference From Another Page'. Save the field. In 'Details' Tab of the field choose the page you created in step 2 Click Save button Choose the images field name for the field that holds your images (on page template from step 2) Click Save button again Choose whether you want to include child pages of page from step 2 to supply images Add the field to any template You are now ready to use the field View of the inputfield on the page edit screen:

      View of the field settings

      The module can be installed from this github repo. Some more info in the README there, too.
      In my tests it was fairly stable. After receiving your valued feedback, I will eventually add it to the modules directory.
      My ideas for further improvement:
      - add ajax loading of thumbnails
      Happy to hear your feedback!
       
    • By gebeer
      Although the PW backend is really intuitive, ever so often my clients need some assistance. Be it they are not so tech savvy or they are not working in the backend often.
      For those cases it is nice to make some help videos available to editors. This is what this module does.
      ProcessHelpVideos Module
      A Process module to display help videos for the ProcessWire CMS. It can be used to make help videos (screencasts) available to content editors.
      This module adds a 'Help Videos" section to the ProcessWire backend. The help videos are accessible through an automatically created page in the Admin page tree. You can add your help videos as pages in the page tree. The module adds a hidden page to the page tree that acts as parent page for the help video pages. All necessary fields and templates will be installed automatically. If there are already a CKEditor field and/or a file field for mp4 files installed in the system, the module will use those. Otherwise it will create the necessary fields. Also the necessary templates for the parent help videos page and it's children are created on module install. The module installs a permission process-helpvideos. Every user role that should have access to the help video section, needs this permission. I use the help video approach on quite a few production sites. It is stable so far and well received by site owners/editors. Up until now I installed required fields, templates and pages manually and then added the module. Now I added all this logic to the install method of the module and it should be ready to share.
      The module and further description on how to use it is available on github: https://github.com/gebeer/ProcessHelpVideos
      If you like to give it a try, I am happy to receive your comments/suggestions here.
    • By Robin S
      A module created in response to the topic here:
      Page List Select Multiple Quickly
      Modifies PageListSelectMultiple to allow you to select multiple pages without the tree closing every time you select a page.
      The screencast says it all:

       
      https://github.com/Toutouwai/PageListSelectMultipleQuickly
      https://modules.processwire.com/modules/page-list-select-multiple-quickly/
    • By gebeer
      Hello all,
      sharing my new module FieldtypeImagePicker. It provides a configurable input field for choosing any type of image from a predefined folder.
      The need for it came up because a client had a custom SVG icon set and I wanted the editors to be able to choose an icon in the page editor.
      It can also be used to offer a choice of images that are used site-wide without having to upload them to individual pages.
      There are no image manipulation methods like with the native PW image field.
      Module and full description can be found on github https://github.com/gebeer/FieldtypeImagePicker
      Kudos to @Martijn Geerts. I used his module FieldTypeSelectFile as a base to build upon.
      Here's how the input field looks like in the page editor:

      Hope it can be of use to someone.
      If you like to give it a try, I'm happy to hear your comments or suggestions for improvement. Eventually this will go in the module directory soon, too.
    • By bernhard
      @Sergio asked about the pdf creation process in the showcase thread about my 360° feedback/survey tool and so I went ahead and set my little pdf helper module to public.
      Description from PW Weekly:
       
      Modules Directory: https://modules.processwire.com/modules/rock-pdf/
      Download & Docs: https://github.com/BernhardBaumrock/RockPDF
       
      You can combine it easily with RockReplacer: 
      See also a little showcase of the RockPdf module in this thread:
       
×
×
  • Create New...