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 eelkenet
      Hi! I've created a small Inputfield module called InputfieldFloatRange which allows you to use an HTML5 <input type="range" ../> slider as an InputField. I needed something like this for a project where the client needs to be able to tweak this value more based on 'a feeling' than just entering a boring old number. Maybe more people can use this so I'm hereby releasing it into the wild. 
      EDIT: You can now install it directly from the Modules directory: http://modules.processwire.com/modules/inputfield-float-range/
       
      What is it?
      The missing range slider Inputfield for Processwire. 
      What does it do?
      This module extends InputfieldFloat and allows you to use HTML5 range sliders for number fields in your templates.
      It includes a visible and editable value field, to override/tweak the value if required.  
      Features
      Min/max values Precision (number of decimals) Optional step value (Read more) Optional manual override of the selected value (will still adhere to the rules above) Configurable rounding of manually entered values (floor, round, ceil, disable) Usage
      Clone / zip repo Install FieldtypeFloatRange, this automatically installs the Inputfield Create new field of type `Float (range)` or convert an existing `Float`, `Integer` or `Text` field. To render the field's value simply echo `$page->field` Demo
      A field with Min=0, Max=1, Step=0.2, Precision=2

      Field with settings Min=0, Max=200, Step=0.25, Precision=2

       
      Todo
      Make the display-field's size configurable (will use the Input Size field setting)  Hopefully become redundant  
      Changelog
      004 (current version)
      - Make rounding of manually entered values configurable (floor, round, ceil or disable)
      - Fix small JS bug when the value-display field was not displayed
      - Update README
      003
      - Code cleanup, add some ModuleInfo data & LICENSE
      - Submit to PW Modules directory (http://modules.processwire.com/modules/inputfield-float-range/)
      002
      - Fix issue where setting the step value to an empty value created problem with validation
      - Make the display-field optional
      001
      - Initial release
       
      Thanks!
       
       
    • By Gadgetto
      Status update links (inside this thread) for SnipWire development will be always posted here:
      2019-10-18
      2019-08-08
      2019-06-15
      2019-06-02
      2019-05-25
      If you are interested, you can test the current state of development:
      https://github.com/gadgetto/SnipWire
      Please note that the software is not yet intended for use in a production system (alpha version).
      If you like, you can also submit feature requests and suggestions for improvement. I also accept pull requests.
      ---- INITIAL POST FROM 2019-05-25 ----
      I wanted to let you know that I am currently working on a new ProcessWire module that fully integrates the Snipcart Shopping Cart System into ProcessWire. (this is a customer project, so I had to postpone the development of my other module GroupMailer).
      The new module SnipWire offers full integration of the Snipcart Shopping Cart System into ProcessWire.
      Here are some highlights:
      simple setup with (optional) pre-installed templates, product fields, sample products (quasi a complete shop system to get started immediately) store dashboard with all data from the snipcart system (no change to the snipcart dashboard itself required) Integrated REST API for controlling and querying snipcart data webhooks to trigger events from Snipcart (new order, new customer, etc.) multi currency support self-defined/configurable tax rates etc. Development is already well advanced and I plan to release the module in the next 2-3 months.
      I'm not sure yet if this will be a "Pro" module or if it will be made available for free.
      I would be grateful for suggestions and hints!
      (please have a look at the screenshots to get an idea what I'm talking about)
       




    • By Robin S
      Another little admin helper module...
      Template Field Widths
      Adds a "Field widths" field to Edit Template that allows you to quickly set the widths of inputfields in the template.

      Why?
      When setting up a new template or trying out different field layouts I find it a bit slow and tedious to have to open each field individually in a modal just to set the width. This module speeds up the process.
      Installation
      Install the Template Field Widths module.
      Config options
      You can set the default presentation of the "Field widths" field to collapsed or open. Field widths entered into the Template Field Widths inputfield are only applied if the Edit Template form is submitted with the Template Field Widths inputfield in an opened state. "Collapsed" is the recommended setting if you think you might also use core inputs for setting field widths in a template context. You can choose Name or Label as the primary identifier shown for the field. The unchosen alternative will become the title attribute shown on hover. You can choose to show the original field width next to the template context field width.  
      https://github.com/Toutouwai/TemplateFieldWidths
      https://modules.processwire.com/modules/template-field-widths/
    • 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

×
×
  • Create New...