Debugging
Tequila provides a simple mechanism for debugging your applications with some built in functions.
This functions display information conditionally so you can add debug information on a running environment without affecting normal users.
How to enable debugging
You can enable the debugging information for the whole system or for specific sections.
Site wide
In:
includes/config.php
Set:
$debug = 1;
or
$debug = true;
Specific sections
You can enable debugging in an specific point i.e. The problematic function by adding:
startdebug();
Specific run
You can also enable debugging for a single run. This is convenient for production systems or teams where you don't want to affect other users.
Simply add the $debug_code to the url you are testing
yoururl?yourvars=somevalues&debug=mydebuggingcodegoeshere*
* Your debugging code can be set in config.php
$debug_code ="yourcode"; (default=12345)
** This can be tricky for JS calls, you can still do it by modifying the JS file and view the content of the response using firebug or opening in another window. Tequila also includes a debug.js library that you can use to view javascript variables.
Debugging functions
startDebug();
Starts a debug session by adding the required JavaScript code to toggle the blocks
* You should only call this on development time as it doesn't depend on configuration.
myecho
Same as echo, plus line breaks
function myecho ($msg)
i.e.
myecho ("This is a debugging call");
mytoggle
Will create a toggable DIV in the page with the content of a var as with print_r, booleans will be converted to true / false as false come as empty in some cases / systems.
The 2d parameter ($myName) will be a link to open / close the div that contain the content of $myVar
function mytoggle($myVar, $myName = "")
i.e.
mytoggle($myObject, "this is my object content");
tabIn
Useful to create visual blocks in the debugging. It creates a div with a larger left margin, pushing all following calls.
function tabIn($msg = "")
i.e.
tabin("Here start my function call");
* you can nest many tabIn calls
tabout
Will close the div created with tabin
function tabOut($msg = "")
i.e.
tabout("here finishes my function call");
tabset
Will close tabs from current level to level passed by parameter
function tabset($tolevel=0)
i.e.
tabIn("1");tabIn("2");tabIn("3");tabIn("4");
myecho ("this is level 4");
tabset(2);
myecho("this will appear in level2");
tabreset
Will reset tab level to 0
function tabreset()
i.e. tabreset();
showcallstack
Use to track the execution calls,same as debug_print_backtrace() function inside a toggle block
This function is very useful when you don't know who or why a certain function is being called.
function showcallstack($myName='')
i.e.
showcallstack("Who's calling insertdata??"');