[Sputnik-list] Announcement of sputnik-debug plugin (proof of concept)

Jim Whitehead II jnwhiteh at gmail.com
Tue Mar 18 18:27:00 GMT+2 2008


Today I threw together a proof of concept plugin for sputnik that
allows you to perform massive debugging and trace analysis on a
running sputnik wiki.  It's not the fastest, it's certainly not the
cleanest, but it happens to work pretty well.  It adds a new link to
the bottom of every page that uses the default wrappers:

http://img529.imageshack.us/img529/4277/debugbuttonac7.png

This button when clicked brings up a tabbed interface that shows any
of the following
 - node - The node object that was passed to the wrapper
 - request - The running request that was passed to the wrapper
 - sputnik - The sputnik instance passed to the wrapped
 - genv - The global environment (minus some blacklisted tables)
 - config - The current sputnik.debug configuration table
 - trace log - A running tracelog of the program's execution

Here are some screenshots:

http://img132.imageshack.us/img132/3775/genvtreeex6.png

This shows the exploration tree for the global environment.  It
properly handles table cycles as well as metatables, so you can really
dig deep to see what is going on and where.

http://img357.imageshack.us/img357/737/tracelogvn9.png

This trace log is accomplished by hooking every function available in
the sputnik and versium global tables.  It then reports each function
call along with the arguments that were passed to it, in hierarchical
order so you can properly trace the execution of a page.

Adding something like statistics that tell you how long you spent in
each function and how much each of them were called is certainly
possible.  I tried to general code as much as possible, but more
importantly I wanted to get something working so I can use it for my
own purposes.

So here it is.  The plugin is available as a rock (sans rockspec)
attached to this email. For the tabs/trees to work you will want to
install the images directory at the root of the web server (for
xavante this is htdocs/images for example).  All of the trees/tabs are
accomplished using JQuery, which is included through a set of
node_defaults.

Some of these tables and trace logs are big.  Very big.  The traffic
on the web server isn't horrible, but depending on the browser you may
have issues with the javascript.

INSTALLATION:

Unzip the sputnik-debug directory into your rocks directory and  make-manifest.
Add the following line to sputnik.cgi or sputnik.lua:

require("sputnik.debug")

You can further enable or disable tabs using the following:

sputnik.debug.config.show.node = false
sputnik.debug.config.show.request = false
sputnik.debug.config.show.sputnik = false
etc.

Hope someone else finds it useful.

- Jim



More information about the Sputnik-list mailing list