PDA

View Full Version : Administrative and Maintenance Tools - Debug Functions - trace and traceQuery


Michael Morris
07-13-2008, 10:00 PM
Minimum PHP version: 5.0.0

This mod is simply a php file that contains a couple of functions I created while developing the PAM webframework. While tiny they are highly useful.

If you are not a developer, do not install this modification - it does absolutely nothing useful on a live board. What is worse it turns on debug mode just in case you forgot the config command to do so and you don't want debug mode to be on with a live board.

There are two functions in the PHP file. You can call them in your plugins at any point after the config.php file has been read.

Installation

Upload the file to your includes folder and add the following line to your config.php file.

include_once('includes/vbDebug.php');

That's it. Until you actually call one of the two functions it does nothing but turn on debug mode.

Using the functions

There are two functions in this package at present and this is what they do...

void trace ( mixed, ...)

Use trace where you would use echo or print_r -- it's smart enough to determine which it needs to be. The function can be overloaded - so if you need to check the status of multiple variables just pile them in. The function sends headers if it can and sets the response type to text/plain - this makes the print_r results well formatted and easy to read. The function then calls debug_backtrace to show you what's on the stack at the point it fired and this incidentally let's you know what file and what line it exists on, so you can't accidentally forget to remove it.

void traceQuery( string )

The traceQuery function takes an sql statement at its argument. It runs the query, then halts execution and prints the time that query took to resolve along with the first row's result set and how many total rows where "raised" by the query. This function exists mainly for big board optimization.

While I'm putting this in the 3.7.2 area this mod works with all versions of vbulltin 3.6 and later.

newmasalaboard
08-05-2009, 04:44 PM
Thanks !!

Installed ...

sockwater
08-05-2009, 09:08 PM
Thanks Michael, handy little functions. I dropped 'em into init_startup on a test installation for now.