X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FManual%2FTutorial%2F07_Debugging.pod;h=99372740de6cecd7aafc09eb70157c8f31611a1d;hb=cbc0e764eeb1de2be9a79c33c76e2a169b795785;hp=5ba238f31b03f9b70655028faab9d2a85e4e1993;hpb=ec3ef4ad2ba72cc751c8c5eccccb705602d87d09;p=catagits%2FCatalyst-Manual.git diff --git a/lib/Catalyst/Manual/Tutorial/07_Debugging.pod b/lib/Catalyst/Manual/Tutorial/07_Debugging.pod index 5ba238f..9937274 100644 --- a/lib/Catalyst/Manual/Tutorial/07_Debugging.pod +++ b/lib/Catalyst/Manual/Tutorial/07_Debugging.pod @@ -56,9 +56,15 @@ L =head1 DESCRIPTION -This chapter of the tutorial takes a brief look at the primary options +This chapter of the tutorial takes a brief look at the primary options available for troubleshooting Catalyst applications. +Source code for the tutorial in included in the F +directory of the Tutorial Virtual machine (one subdirectory per +chapter). There are also instructions for downloading the code in +L. + + Note that when it comes to debugging and troubleshooting, there are two camps: @@ -79,12 +85,12 @@ Catalyst is able to easily accommodate both styles of debugging. =head1 LOG STATEMENTS -Folks in the former group can use Catalyst's C<$c-Elog> facility. -(See L for more detail.) For example, if -you add the following code to a controller action method: +Folks in the former group can use Catalyst's C<$c-Elog> facility. +(See L for more detail.) For example, if you add the +following code to a controller action method: $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 @@ -93,8 +99,8 @@ template view use: [% c.log.debug("This is a test log message") %] -As with many other logging facilities, a method is defined for -each of the following "logging levels" (in increasing order of +As with many other logging facilities, a method is defined for each of +the following "logging levels" (in increasing order of severity/importance): $c->log->debug @@ -103,9 +109,21 @@ severity/importance): $c->log->error $c->log->fatal -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 Data::Dumper in both Catalyst code and in TT templates. +For use in Catalyst code: + + use Data::Dumper; + $c->log->debug("\$var is: ".Dumper($c->stash->{something})); + +and TT templates: + + [% USE Dumper ; Dumper.dump(c.stash.something) %]. + +B Whether you are a logging fanatic or not, we strongly recommend +that you take advantage of L or L. It's +easy to use L with either of these and they will provide +a huge amount of extra functionality that you will want in virtually +every production application you run or support. =head1 RUNNING CATALYST UNDER THE PERL DEBUGGER @@ -129,14 +147,15 @@ you can obviously indent them if you prefer): # Retrieve all of the book records as book model objects and store in the # stash where they can be accessed by the TT template $c->stash->{books} = [$c->model('DB::Book')->all]; - + # Set the TT template to use. You will almost always want to do this # in your action methods. $c->stash->{template} = 'books/list.tt2'; } -This causes the Perl Debugger to enter "single step mode" when this command is -encountered (it has no effect when Perl is run without the C<-d> flag). +This causes the Perl Debugger to enter "single step mode" when this +command is encountered (it has no effect when Perl is run without the +C<-d> flag). B The C here is the Perl Debugger, not the DB model. @@ -144,8 +163,8 @@ If you haven't done it already, enable SQL logging as before: $ export DBIC_TRACE=1 -To now run the Catalyst development server under the Perl debugger, simply -prepend C to the front of C