X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Manual.git;a=blobdiff_plain;f=lib%2FCatalyst%2FManual%2FTutorial%2FDebugging.pod;h=fe78ff2752663562b30b866d245a0b8ba8b9bc92;hp=6a958d3dfa32b971748e7327605081afb621c45e;hb=3b1fa91be1d89d2297aa9e8e83462344d9cd9820;hpb=5e6026272f809951ac22fae43b73d2c1dc79c7fc diff --git a/lib/Catalyst/Manual/Tutorial/Debugging.pod b/lib/Catalyst/Manual/Tutorial/Debugging.pod index 6a958d3..fe78ff2 100644 --- a/lib/Catalyst/Manual/Tutorial/Debugging.pod +++ b/lib/Catalyst/Manual/Tutorial/Debugging.pod @@ -1,10 +1,11 @@ =head1 NAME -Catalyst::Manual::Tutorial::Debugging - Catalyst Tutorial - Part 6: Debugging +Catalyst::Manual::Tutorial::Debugging - Catalyst Tutorial - Chapter 7: Debugging + =head1 OVERVIEW -This is B for the Catalyst tutorial. +This is B for the Catalyst tutorial. L @@ -20,30 +21,34 @@ L =item 3 -L +L =item 4 -L +L =item 5 -L +L =item 6 -B +L =item 7 -L +B =item 8 -L +L =item 9 +L + +=item 10 + L =back @@ -51,7 +56,7 @@ L =head1 DESCRIPTION -This part 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. Note that when it comes to debugging and troubleshooting, there are two @@ -71,26 +76,38 @@ 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-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); + $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 -view use: +with the other debug output. To accomplish the same thing in a TT +template view use: + + [% c.log.debug("This is a test log message") %] - [% Catalyst.log.debug("This is a test log message") %] +As with many other logging facilities, you a method is defined for +each of the following "logging levels" (in increasing order of +severity/importance): + + $c->log->debug + $c->log->info + $c->log->warn + $c->log->error + $c->log->fatal You can also use L in both Catalyst code -(Clog-Edebug("$var is: ".Dumper($var));)>) +(Clog-Edebug("\$var is: ".Dumper($var));)>) and TT templates (C<[% Dumper.dump(book) %]>. + =head1 RUNNING CATALYST UNDER THE PERL DEBUGGER Members of the interactive-debugger fan club will also be at home with @@ -102,7 +119,7 @@ C line as follows inside the C method (I like to you can obviously indent them if you prefer): sub list : Local { - # Retrieve the usual perl OO '$self' for this object. $c is the Catalyst + # Retrieve the usual Perl OO '$self' for this object. $c is the Catalyst # 'Context' that's used to 'glue together' the various components # that make up the application my ($self, $c) = @_; @@ -111,7 +128,7 @@ 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('MyAppDB::Book')->all]; + $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. @@ -121,6 +138,12 @@ you can obviously indent them if you prefer): 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. + +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