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=b03f2a76e4d15b7c1f4aeab6cec96ba209c15efd;hp=90222e96f1dd7e58b1b650a1acda2d97fa4c2adb;hb=5fe0e6dd6d3c9a21c48c9c1a671a6092222a98d9;hpb=d04961970a25ec3dc831f89be5cd6e27fdec884a diff --git a/lib/Catalyst/Manual/Tutorial/Debugging.pod b/lib/Catalyst/Manual/Tutorial/Debugging.pod index 90222e9..b03f2a7 100644 --- a/lib/Catalyst/Manual/Tutorial/Debugging.pod +++ b/lib/Catalyst/Manual/Tutorial/Debugging.pod @@ -76,26 +76,28 @@ 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); 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: - [% Catalyst.log.debug("This is a test log message") %] + [% c.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) %]>. + =head1 RUNNING CATALYST UNDER THE PERL DEBUGGER Members of the interactive-debugger fan club will also be at home with @@ -137,12 +139,12 @@ This will start the interactive debugger and produce output similar to: $ perl -d script/myapp_server.pl - Loading DB routines from perl5db.pl version 1.27 + Loading DB routines from perl5db.pl version 1.3 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. - main::(script/myapp_server.pl:14): my $debug = 0; + main::(script/myapp_server.pl:16): my $debug = 0; DB<1> @@ -156,8 +158,8 @@ in. Once the breakpoint is encountered in the C method, the console session running the development server will drop to the Perl debugger prompt: - MyApp::Controller::Books::list(/home/me/MyApp/script/../lib/MyApp/Controller/Books.pm:40): - 40: $c->stash->{books} = [$c->model('DB::Books')->all]; + MyApp::Controller::Books::list(/home/me/MyApp/script/../lib/MyApp/Controller/Books.pm:48): + 48: $c->stash->{books} = [$c->model('DB::Books')->all]; DB<1> @@ -168,8 +170,8 @@ C into methods/subroutines): DB<1> n SELECT me.id, me.authors, me.title, me.rating FROM books me: - MyApp::Controller::Books::list(/home/me/MyApp/script/../lib/MyApp/Controller/Books.pm:44): - 44: $c->stash->{template} = 'books/list.tt2'; + MyApp::Controller::Books::list(/home/me/MyApp/script/../lib/MyApp/Controller/Books.pm:53): + 53: $c->stash->{template} = 'books/list.tt2'; DB<1> @@ -183,15 +185,11 @@ Next, list the methods available on our C model: () (0+ (bool - MODIFY_CODE_ATTRIBUTES - _attr_cache - _collapse_result - _construct_object - _count - _result_class_accessor - _result_source_accessor - all - carp + __source_handle_accessor + _add_alias + _build_unique_query + _calculate_score + _collapse_cond DB<2> @@ -279,7 +277,7 @@ debugging: Check the version of an installed module: - perl -MModule::Name -e 'print $Module::Name::VERSION;' + perl -MEmod_nameE -e '"print $Emod_nameE::VERSION\n"' For example: @@ -305,13 +303,37 @@ Otherwise, it returns undef and nothing will be printed. =back +=head1 TT DEBUGGING + +If you run into issues during the rendering of your template, it might +be helpful to enable TT C options. You can do this in a Catalyst +environment by adding a C line to the C<__PACKAGE__->config> +declaration in C: + + __PACKAGE__->config({ + TEMPLATE_EXTENSION => '.tt2', + DEBUG => 'undef', + }); + +There are a variety of options you can use, such as 'undef', 'all', +'service', 'context', 'parser' and 'provider'. See +L for more information +(remove the C portion of the name shown in the TT docs and +convert to lower case for use inside Catalyst). + +B B (especially the 'undef' option -- leaving this +enabled will conflict with several of the conventions used by this +tutorial to leave some variables undefined on purpose). + + =head1 AUTHOR Kennedy Clark, C Please report any errors, issues or suggestions to the author. The most recent version of the Catalyst Tutorial can be found at -L. +L. -Copyright 2006, Kennedy Clark, under Creative Commons License -(L). +Copyright 2006-2008, Kennedy Clark, under Creative Commons License +(L).