Developer and Debug Mode
Movable Type has a built in developer mode that modifies the behavior of the application slightly to make it easier for developers to build, test and debug plugins they are building on top of Movable Type. When in “DebugMode” the application will:
- Monitor the API plugins use and report any issues, discrepancies or ways in which the plugin may not be fully compatible with MT4.
- Use the non-compressed javascript files allowing javascript debuggers to more easily report specific line numbers and files in which problems may be occurring
- Use non-compressed CSS files allowing debuggers to report more precisely about what stylesheet problems may exist
- The
devel.jsjavascript file will be included on each page of the application. This javascript file outputs log information to the browser console so that plugins like Firefox’s FireBug can capture and report to developers debugging information about javascript code running on the page. IE and Safari users will have this information displayed to them through javascript pop-ups. - And warnings emanating from plugin code or perl code will be displayed at the bottom of the page. This provides a nice linting framework for reporting possible issues with the plugin.
Prerequisites
- Users should install the Time::HiRes perl module prior to enabling DebugMode
Turning On Debug Mode
To turn on Debug Mode within Movable Type, edit your mt-config.cgi file and add the following line:
DebugMode 1
The DebugMode is a bit-wise setting and offers the following options:
- 1 - Display debug messages
- 2 - Display a stack trace for messages captured
- 4 - Lists queries issued by Data::ObjectDriver
- 8 - Reports on MT templates that take more than 1/4 second to build*
- 128 - Outputs app-level request/response information to STDERR.
These can be combined, so if you want to display queries and debug messages, use a DebugMode of 5 for instance.
Debugging Template Tags
By setting the DebugMode to a value of 8, you can get some performance information about your template tags. These messages get sent to your web servers error log or STDERR. He is some sample output:
Builder: Tag [Assets] - 12.007559 seconds
Builder: Tag [Tags] - 0.877185 seconds
Builder: Tag [If] - 0.877515 seconds
Builder: Tag [Include] - 1.063821 seconds
Builder: Tag [Else] - 1.064076 seconds
Builder: Tag [If] - 1.064391 seconds
Plugin Compatibility
When Debug Mode is enabled, Movable Type will report for each enabled plugin the use of any deprecated API. This is a very simple way for example to ensure that your plugins do not make calls to methods or subroutines that might in the future be removed. The screenshot below shows what type of information is displayed when DebugMode is set to “1”.
Mark Carey on September 6, 2007, 1:06 p.m. 返信
Is there a way for a developer to log debug messages to the pop-up cascading debug log? Or is that strictly for javascript? It would be great, while debugging a plugin, to log messages to such a “live” log…