From: Tomas Doran Date: Sun, 28 Mar 2010 18:18:45 +0000 (+0000) Subject: More splitting up of the response logging methods X-Git-Tag: 5.80022~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=75b658164c8db8bec31f4d29f198402d6f6bc110 More splitting up of the response logging methods --- diff --git a/Changes b/Changes index 3db89ea..9beb3e4 100644 --- a/Changes +++ b/Changes @@ -6,9 +6,10 @@ Refactoring / optimizations: - Display of the end of hit debug messages has been factored out into - log_headers, log_request, log_request_headers, log_response and - log_response_headers methods so that plugins which customise how - much information is shown on the debug screen as easy to write. + log_headers, log_request, log_request_headers, log_response, + log_response_status_line and log_response_headers methods so that + plugins which customise how much information is shown on the debug + screen as easy to write. - Make all logging of request and response state get the information from $c->dump_these so that there is a unified point from which to hook in parameter filtering (for example). diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 58c0505..bb2bad5 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -2145,7 +2145,26 @@ sub log_request { =head2 $c->log_response -Writes information about the response to the debug logs. This includes: +Writes information about the response to the debug logs by calling +C<< $c->log_response_status_line >> and C<< $c->log_response_headers >>. + +=cut + +sub log_response { + my $c = shift; + + return unless $c->debug; + + my($dump) = grep {$_->[0] eq 'Response' } $c->dump_these; + my $response = $dump->[1]; + + $c->log_response_status_line($response); + $c->log_response_headers($response->headers); +} + +=head2 $c->log_response_status_line($response) + +Writes one line of information about the response to the debug logs. This includes: =over 4 @@ -2159,13 +2178,8 @@ Writes information about the response to the debug logs. This includes: =cut -sub log_response { - my $c = shift; - - return unless $c->debug; - - my($dump) = grep {$_->[0] eq 'Response' } $c->dump_these; - my $response = $dump->[1]; +sub log_response_status_line { + my ($c, $response) = @_; $c->log->debug( sprintf( @@ -2177,6 +2191,15 @@ sub log_response { ); } +=head2 $c->log_response_headers($headers); + +Hook method which can be wrapped by plugins to log the responseheaders. +No-op in the default implementation. + +=cut + +sub log_response_headers {} + =head2 $c->log_request_parameters( query => {}, body => {} ) Logs request parameters to debug logs