Get rid of more "the ... manpage" POD things
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Manual / Tutorial / Debugging.pod
index d65f842..1197774 100644 (file)
@@ -2,8 +2,6 @@
 
 Catalyst::Manual::Tutorial::Debugging - Catalyst Tutorial - Part 6: Debugging
 
-
-
 =head1 OVERVIEW
 
 This is B<Part 6 of 9> for the Catalyst tutorial.
@@ -46,18 +44,18 @@ L<AdvancedCRUD|Catalyst::Manual::Tutorial::AdvancedCRUD>
 
 =item 9
 
-L<Appendicies|Catalyst::Manual::Tutorial::Appendicies>
+L<Appendices|Catalyst::Manual::Tutorial::Appendices>
 
 =back
 
 
-
 =head1 DESCRIPTION
 
 This part of the tutorial takes a brief look at the primary options
 available for troubleshooting Catalyst applications.
 
-Note that when it comes to debugging and troubleshooting, there are two camps:
+Note that when it comes to debugging and troubleshooting, there are two
+camps:
 
 =over 4
 
@@ -73,31 +71,29 @@ Fans of interactive debuggers.
 
 Catalyst is able to easily accommodate both styles of debugging.
 
-
-
 =head1 LOG STATEMENTS
 
 Folks in the former group can use Catalyst's C<$c-E<gt>log> facility.
-For example, if you add the following code to a controller action
-method:
+(See L<Catalyst::Log> for more detail.) For example, if you add the
+following code to a controller action method:
 
-    $c->log->debug("This is a test log message");
+    $c->log->info("Starting the foreach loop here");
+
+    $c->log->debug("Value of $id is: ".$id);
 
 Then the Catalyst development server will display your message along
-with the other debug output.  To accomplish the same thing in a TTSite
+with the other debug output. To accomplish the same thing in a TTSite
 view use:
 
     [% Catalyst.log.debug("This is a test log message") %]
 
-You can also use L<Data::Dumper|Data::Dumper> in both Catalyst code
-(C<$c-E<gt>log-E<gt>dumper($myvar)>) and TT templates (C<[%
-Dumper.dump(book) %]> as discussed in earlier parts of the tutorial.
-
-
+You can also use L<Data::Dumper|Data::Dumper> in both Catalyst code 
+(C<use Data::Dumper; $c-E<gt>log-E<gt>debug("$var is: ".Dumper($var));)>) 
+and TT templates (C<[% Dumper.dump(book) %]>.
 
 =head1 RUNNING CATALYST UNDER THE PERL DEBUGGER
 
-Members of the interactive debuggers fan club will also be at home with
+Members of the interactive-debugger fan club will also be at home with
 Catalyst applications.  One approach to this style of Perl debugging is
 to embed breakpoints in your code.  For example, open
 C<lib/MyApp/Controller/Books.pm> in your editor and add the
@@ -234,6 +230,65 @@ and C<perldebtut>.  You can also type C<h> or C<h h> 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<lib> directory of your Catalyst project.  
+When Catalyst loads, it will load from inside your C<lib> 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.
+
+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<Catalyst::Plugin::Authentication|Catalyst::Plugin::Authentication>
+with the following command:
+
+    mkdir -p lib/Catalyst/Plugin; cp \
+        `perldoc -l Catalyst::Plugin::Authentication` lib/Catalyst/Plugin
+
+B<Note:> 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<can> method returns a coderef.
+Otherwise, it returns undef and nothing will be printed.
+
+=back
+
 
 =head1 AUTHOR
 
@@ -241,7 +296,5 @@ Kennedy Clark, C<hkclark@gmail.com>
 
 Please report any errors, issues or suggestions to the author.
 
-Copyright 2006, Kennedy Clark, under Creative Commons License (L<http://creativecommons.org/licenses/by-nc-sa/2.5/>).
-
-Version: .94
-
+Copyright 2006, Kennedy Clark, under Creative Commons License
+(L<http://creativecommons.org/licenses/by-nc-sa/2.5/>).