adrian Posted February 13, 2016 Share Posted February 13, 2016 Tracy Debugger for ProcessWire The ultimate “swiss army knife” debugging and development tool for the ProcessWire CMF/CMS Integrates and extends Nette's Tracy debugging tool and adds 35+ custom tools designed for effective ProcessWire debugging and lightning fast development The most comprehensive set of instructions and examples is available at: https://adrianbj.github.io/TracyDebugger Modules Directory: http://modules.processwire.com/modules/tracy-debugger/ Github: https://github.com/adrianbj/TracyDebugger A big thanks to @tpr for introducing me to Tracy and for the idea for this module and for significant feedback, testing, and feature suggestions. 40 3 Link to comment Share on other sites More sharing options...
pwired Posted February 13, 2016 Share Posted February 13, 2016 You did it again adrian, big thanks for this. 1 Link to comment Share on other sites More sharing options...
tpr Posted February 13, 2016 Share Posted February 13, 2016 Good stuff! I was hoping to see a more feminine screenshot too 2 Link to comment Share on other sites More sharing options...
kixe Posted February 13, 2016 Share Posted February 13, 2016 Many Thanks. This will be a first choice development tool. 1 Link to comment Share on other sites More sharing options...
adrian Posted February 13, 2016 Author Share Posted February 13, 2016 Thanks to a bug report from horst I just committed a new version that fixes a Windows directory path issue. He also pointed me to another problem which is turns out means that this module currently only works with the 3.x branch of PW. I will look into supporting 2.x, but for the moment if you want to test, you will need 3.x or you can probably make it work on 2.7 if you uncheck "Show ProcessWire Panel" in the config settings. You'll miss out on that functionality, but hopefully everything else should work. 1 Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted February 13, 2016 Share Posted February 13, 2016 That is something nearly every developer can make use of. Thanks adrian and tpr! Could you please suggest a proper way to debug process modules stuff with it? On the tracy page I have read about outputting stuff to fiebug... Link to comment Share on other sites More sharing options...
adrian Posted February 13, 2016 Author Share Posted February 13, 2016 (edited) On 2/13/2016 at 7:22 PM, Ivan Gretsky said: That is something nearly every developer can make use of. Thanks adrian and tpr! Could you please suggest a proper way to debug process modules stuff with it? On the tracy page I have read about outputting stuff to fiebug... Thanks Ivan, there are several options - Firebug is actually something I haven't implement yet in this module. It requires an additional package which I haven't included. I figure that most of us are on Chrome, so didn't bother with it yet. But if there is interest, I will definitely take a look. I should have pointed to the best of the Tracy docs: https://doc.nette.org/en/2.3/debugging - for some reason the ones on the main page don't include the barDump() option yet. You can use: TD::dump(), TD::barDump(), TD::log() I also implemented some aliases - d(), bd(), l() as very short options for lazy typists, but not sure about keeping these due to possible name conflicts. Anyway, let me know if that links helps and if you have any specific questions. Edited February 13, 2016 by adrian Corrected info about the Firebug option. Link to comment Share on other sites More sharing options...
adrian Posted February 13, 2016 Author Share Posted February 13, 2016 Thanks everyone for the great interest in this module! I have just added 2 new sections to the PW panel that shows details of all fields on the current page. I would love to hear from you if you have any ideas for other sections/info that you would find useful to have in the PW panel. List View Shows basic details with the name linked to the edit page for that field: Object View Shows the fields object - for details of each field, expand the "data" section: 4 Link to comment Share on other sites More sharing options...
adrian Posted February 13, 2016 Author Share Posted February 13, 2016 Sorry, this is just too much fun Just added a Current Page Info section, with links to edit the page (from the name), edit the template, and open the page tree with this page expanded to show the children (from the number of children). 3 Link to comment Share on other sites More sharing options...
tpr Posted February 13, 2016 Share Posted February 13, 2016 Looks like you're really in love with Tracy 2 Link to comment Share on other sites More sharing options...
adrian Posted February 13, 2016 Author Share Posted February 13, 2016 On 2/13/2016 at 9:52 PM, tpr said: Looks like you're really in love with Tracy Actually I am, and have been for 18 years now, but that is a very different kind of love 4 Link to comment Share on other sites More sharing options...
tpr Posted February 13, 2016 Share Posted February 13, 2016 That was high time then to make a module from it Page Info: it's useful, but it's a bit inconvenient to show. How about adding it to a separate tab? That way it would only require to hover. I don't know how much work is it, just asking. Link to comment Share on other sites More sharing options...
adrian Posted February 14, 2016 Author Share Posted February 14, 2016 On 2/13/2016 at 10:10 PM, tpr said: That was high time then to make a module from it Page Info: it's useful, but it's a bit inconvenient to show. How about adding it to a separate tab? That way it would only require to hover. I don't know how much work is it, just asking. New tab/panel isn't hard to do at all, but I wonder whether just having that section always expanded would be ok/better? There are so many options and ways to present info that I am not totally sure the best option yet. I'd really love some thoughts from others about what they think they would use/access most often. Perhaps I could add several PW tabs/panels with different elements on each. Anyone have any ideas on what else they would like to have accessible and what should be grouped with what? EDIT: I have just made the Page Info section open by default so a hover over the PW tab is enough to see that info. Still amenable to making separate tabs/panels if that is the consensus though. 1 Link to comment Share on other sites More sharing options...
tpr Posted February 14, 2016 Share Posted February 14, 2016 I like the way it works now, thanks! 1 Link to comment Share on other sites More sharing options...
adrian Posted February 14, 2016 Author Share Posted February 14, 2016 Just been playing around with shortcuts to the various dump/log methods. TD::dump() TD::barDump() TD::log() TD::fireLog() TD::timer() You can now also use these shortcuts/aliases: TD::dump($var) dump() d() TD::barDump($var, $title) barDump() bd() TD::log($message) l() Just in case you are wondering, log() is already defined in PW, which is why it is not included here. TD::fireLog($message) fireLog() fl() TD:timer($name) timer() t() These aliases/shortcuts can be disabled in the module config setting, either altogether, or individually, just in case you have functions with the same names defined them elsewhere on your site and are getting a "previously declared" error. I'd really appreciate any feedback on these shortcuts/aliases - I think they make dumping/logging substantially quicker, but I am definitely open to suggestion/criticisms to this approach. Link to comment Share on other sites More sharing options...
adrian Posted February 14, 2016 Author Share Posted February 14, 2016 In followup to that last post, I decided to add an option to load the Tracy library for non-superusers. This will NOT show errors or the debug bar for non-superusers. It just loads the Tracy library so that you can call Tracy methods directly, eg. Tracy\Debugger::dump() without non-superusers getting a "Fatal error: Class \'Tracy\Debugger\' not found" fatal error. The downside to this setting is that the library is loaded for everyone - while it may not be a significant increase in resources, it is still something, so in general I recommend leaving this unchecked. Link to comment Share on other sites More sharing options...
tpr Posted February 14, 2016 Share Posted February 14, 2016 How about making a dummy Tracy class with barDump/dump/log methods to load for non-superusers? (as a workaround) This way less resources would be needed. 1 Link to comment Share on other sites More sharing options...
adrian Posted February 14, 2016 Author Share Posted February 14, 2016 On 2/14/2016 at 5:12 PM, tpr said: How about making a dummy Tracy class with barDump/dump/log methods to load for non-superusers? (as a workaround) This way less resources would be needed. I think that sounds like a decent approach, so I just implemented it. Now there is no need to worry if for some reason you want to make direct calls via (Tracy\Debugger::method()) on a live site as non-superusers will just get the dummy methods which return nothing. I also just implemented the TD::timer() method, along with timer() and t() shortcut aliases. With timer() you can do: t(); // insert resource intensive code here bd(t()); to dump the results of the time to the debug bar. 1 Link to comment Share on other sites More sharing options...
matjazp Posted February 14, 2016 Share Posted February 14, 2016 t() returns number like 3.0994415283203e-6 Could that be "better" formated? Link to comment Share on other sites More sharing options...
adrian Posted February 14, 2016 Author Share Posted February 14, 2016 On 2/14/2016 at 6:49 PM, matjazp said: t() returns number like 3.0994415283203e-6 Could that be "better" formated? Sure, it is now rounded to 4 decimal places. This matches the precision of PW's built in Debug::timer() which of course you could also use and dump or bardump to Tracy. Is that what you were getting at? I have also added the name of the timer to the output - if you specify it like: t('first'); sleep(1); bd(t('first')); t('second'); sleep(2); bd(t('second')); This way you can have multiple timers and output them at once, and know which value responds to which timer. Please let me know if that is better for you, or if you have any more specific suggestions. Link to comment Share on other sites More sharing options...
adrian Posted February 14, 2016 Author Share Posted February 14, 2016 I just added the fireLog method: TD::fireLog() fireLog() fl() To make this work you need to have added these extensions: Chrome: https://github.com/MattSkala/chrome-firelogger Firefox: http://www.getfirebug.com/ http://firelogger.binaryage.com/ Link to comment Share on other sites More sharing options...
tpr Posted February 14, 2016 Share Posted February 14, 2016 There's a typo in the name of "ShortcutMethods": the first "S" is lowercase in the filename which causes an error (perhaps not on every server). Link to comment Share on other sites More sharing options...
matjazp Posted February 14, 2016 Share Posted February 14, 2016 4 decimal places is ok (from my point of view), but now it show 0.0 instead of 0.0000 Link to comment Share on other sites More sharing options...
adrian Posted February 14, 2016 Author Share Posted February 14, 2016 On 2/14/2016 at 7:33 PM, tpr said: There's a typo in the name of "ShortcutMethods": the first "S" is lowercase in the filename which causes an error (perhaps not on every server). That's weird - it was actually a git issue - I had already changed the filename locally to match the require statement, but git didn't update it when syncing. Looks to be fixed now. 1 Link to comment Share on other sites More sharing options...
adrian Posted February 14, 2016 Author Share Posted February 14, 2016 On 2/14/2016 at 7:36 PM, matjazp said: 4 decimal places is ok (from my point of view), but now it show 0.0 instead of 0.0000 Weird - I am not seeing that at all - could you please post exactly how you are calling this? Also, how many times have you reloaded the page. As you can image if the result was 3.100000000 it would round to be 3.1, rather than 3.1000, although it seems unlikely that the result would only have 2 significant figures. I am wondering what might be different on your setup. I don't see why PHP version would matter and can't think of anything else. Anyone else out there seeing only one decimal place? Link to comment Share on other sites More sharing options...
Recommended Posts