10.5. Debugging

 < Day Day Up > 

While it's always nice when your code runs perfectly the first time you use it, you probably will have to spend some time debugging your RT extensions.

Debugging web applications can be tricky. If you can write a standalone script to exercise a piece of code, you can use Perl's debugger. Run perldoc perldebug for details.

If your code is dependent on being run in the web environment, then you cannot use the debugger.

10.5.1. RT's Logging System

You can use RT's own logging system in your extensions, which is useful for debugging. RT uses Log::Dispatch from CPAN to implement debugging. This module has a very simple API for logging messages. You simply call a method name matching the log level you want to use, and pass it a message:

     $RT::Logger->debug("entering bake_cake method");           $RT::Logger->critical("cannot contact the mothership!"); 

RT configures Log::Dispatch to add additional information to your message, including a timestamp and the file and line number where the message was generated. Logging can be configured in the etc/RT_SiteConfig.pm file to go to the screen, a file, or to use syslog.

For development, you should configure at least one of the log outputs to run at the "debug" level, which is the lowest posssible level, ensuring that you see all the messages that are generated.

     < Day Day Up > 

    RT Essentials
    RT Essentials
    ISBN: 0596006683
    EAN: 2147483647
    Year: 2005
    Pages: 166

    Similar book on Amazon

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net