X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FManual%2FTutorial%2FDebugging.pod;h=6a958d3dfa32b971748e7327605081afb621c45e;hb=a4804358868199fe9ec2c98becadaa3b469a1a4f;hp=adc4d62e2e95cf724944019527691ae82782f202;hpb=c19d127ebfc41407188cbb614c47635b312aad7e;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Manual/Tutorial/Debugging.pod b/lib/Catalyst/Manual/Tutorial/Debugging.pod index adc4d62..6a958d3 100644 --- a/lib/Catalyst/Manual/Tutorial/Debugging.pod +++ b/lib/Catalyst/Manual/Tutorial/Debugging.pod @@ -87,9 +87,9 @@ view use: [% Catalyst.log.debug("This is a test log message") %] -You can also use L in both Catalyst code (Clog-Edebug("$var is: ".Dumper($var));)>) and -TT templates (C<[% Dumper.dump(book) %]>. +You can also use L in both Catalyst code +(Clog-Edebug("$var is: ".Dumper($var));)>) +and TT templates (C<[% Dumper.dump(book) %]>. =head1 RUNNING CATALYST UNDER THE PERL DEBUGGER @@ -167,9 +167,8 @@ C into methods/subroutines): DB<1> This takes you to the next line of code where the template name is set. -Notice that because we enabled C -earlier, SQL debug output also shows up in the development server debug -output. +Notice that because we enabled C earlier, SQL debug +output also shows up in the development server debug information. Next, list the methods available on our C model: @@ -229,14 +228,76 @@ For more information on using the Perl debugger, please see C and C. You can also type C or C at the debugger prompt to view the built-in help screens. + +=head1 DEBUGGING MODULES FROM CPAN + +Although the techniques discussed above work well for code you are +writing, what if you want to use print/log/warn messages or set +breakpoints in code that you have installed from CPAN (or in module that +ship with Perl)? One helpful approach is to place a copy of the module +inside the C directory of your Catalyst project. When Catalyst +loads, it will load from inside your C directory first, only +turning to the global modules if a local copy cannot be found. You can +then make modifications such as adding a C<$DB::single=1> to the local +copy of the module without risking the copy in the original location. +This can also be a great way to "locally override" bugs in modules while +you wait for a fix on CPAN. + + +Matt Trout has suggested the following shortcut to create a local +copy of an installed module: + + mkdir -p lib/Module; cp `perldoc -l Module::Name` lib/Module/ + +For example, you could make a copy of +L +with the following command: + + mkdir -p lib/Catalyst/Plugin; cp \ + `perldoc -l Catalyst::Plugin::Authentication` lib/Catalyst/Plugin + +B Matt has also suggested the following tips for Perl +debugging: + +=over 4 + +=item * + +Check the version of an installed module: + + perl -MModule::Name -e 'print $Module::Name::VERSION;' + +For example: + + $ perl -MCatalyst::Plugin::Authentication -e \ + 'print $Catalyst::Plugin::Authentication::VERSION;' + 0.07 + +=item * + +Check if a modules contains a given method: + + perl -MModule::Name -e 'print Module::Name->can("method");' + +For example: + + $ perl -MCatalyst::Plugin::Authentication -e \ + 'print Catalyst::Plugin::Authentication->can("prepare");' + CODE(0x9c8db2c) + +If the method exists, the Perl C method returns a coderef. +Otherwise, it returns undef and nothing will be printed. + +=back + + =head1 AUTHOR Kennedy Clark, C -Please report any errors, issues or suggestions to the author. +Please report any errors, issues or suggestions to the author. The +most recent version of the Catalyst Tutorial can be found at +L. Copyright 2006, Kennedy Clark, under Creative Commons License (L). - -Version: .94 -