monkinetic weblog

Steve Ivy's Weblog - Since 1999 - XII Ed.

PluginDebug: Proof-of-concept Debug Logging for MT::Plugin

As a developer for SixApart Services, one thing I do a lot of is put debug code in plugins I’m working on to output values to Movable Type’s backend activity log. This can get messy, and I usually end up writing a one-off debuglog function for each plugin to make this more convenient.

Well, I finally got tired of the run-around and wrote a proof-of-concept plugin that adds a debuglog function to MT::Plugin.

It works by looking for a config directive in mt-config.cgi:

PluginDebug mypluginid, myotherpluginid

If the id of the currentplugin is in that list, then calling:

$plugin->debuglog($msg);

…will add the message to the activity log with a log level of debug. For the lazy, you can also use ‘all’ as the value of PluginDebug:

PluginDebug all

And any call to $plugin->debug will get logged. My hope is to see this get added to MT core soon (hence the “proof of concept” status) but I welcome any thoughts on how to make this better for developers.

My name is Steve Ivy and I write about technology, the open web, social software, and general nerdity on monkinetic.com. You should follow me on Twitter or subscribe to this blog if you like what you're reading. I spend my days hacking Movable Type, python, Django, and various other efforts at Wallrazer. This is my personal site.