X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst.pm;h=13c813aca0e6dc96150c1b1ff93865840ffaae80;hb=3f7d86f8303cd1d3f1d4ffa04bba510fc3a93d98;hp=d2c045ff4688822b1effdcb7134f877dd2eb80cd;hpb=697bab77af486790c35c1afe7964dea3279a0d01;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index d2c045f..13c813a 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -78,10 +78,7 @@ __PACKAGE__->stats_class('Catalyst::Stats'); # Remember to update this in Catalyst::Runtime as well! -our $VERSION = '5.80021'; -our $PRETTY_VERSION = $VERSION; - -$VERSION = eval $VERSION; +our $VERSION = '5.80022'; sub import { my ( $class, @arguments ) = @_; @@ -1162,7 +1159,7 @@ EOF if ( $class->debug ) { my $name = $class->config->{name} || 'Application'; - $class->log->info("$name powered by Catalyst $Catalyst::PRETTY_VERSION"); + $class->log->info("$name powered by Catalyst $Catalyst::VERSION"); } # Make sure that the application class becomes immutable at this point, @@ -2108,8 +2105,6 @@ Writes information about the request to the debug logs. This includes: =item * Request method, path, and remote IP address -=item * Request headers (see L) - =item * Query keywords (see L) =item * Request parameters @@ -2134,7 +2129,7 @@ sub log_request { $address ||= ''; $c->log->debug(qq/"$method" request for "$path" from "$address"/); - $c->log_headers('request', $request->headers); + $c->log_request_headers($request->headers); if ( my $keywords = $request->query_keywords ) { $c->log->debug("Query keywords are: $keywords"); @@ -2147,15 +2142,8 @@ sub log_request { =head2 $c->log_response -Writes information about the response to the debug logs. This includes: - -=over 4 - -=item * Response status code - -=item * Response headers (see L) - -=back +Writes information about the response to the debug logs by calling +C<< $c->log_response_status_line >> and C<< $c->log_response_headers >>. =cut @@ -2167,6 +2155,29 @@ sub log_response { 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 + +=item * Response status code + +=item * Content-Type header (if present) + +=item * Content-Length header (if present) + +=back + +=cut + +sub log_response_status_line { + my ($c, $response) = @_; + $c->log->debug( sprintf( 'Response Code: %s; Content-Type: %s; Content-Length: %s', @@ -2177,6 +2188,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 @@ -2233,6 +2253,15 @@ sub log_request_uploads { } } +=head2 $c->log_request_headers($headers); + +Hook method which can be wrapped by plugins to log the request headers. +No-op in the default implementation. + +=cut + +sub log_request_headers {} + =head2 $c->log_headers($type => $headers) Logs L (either request or response) to the debug logs. @@ -2246,7 +2275,8 @@ sub log_headers { return unless $c->debug; - my $t = Text::SimpleTable->new( [ 35, 'Header Name' ], [ 40, 'Value' ] ); + my $column_width = Catalyst::Utils::term_width() - 28; + my $t = Text::SimpleTable->new( [ 15, 'Header Name' ], [ $column_width, 'Value' ] ); $headers->scan( sub { my ( $name, $value ) = @_; @@ -2757,13 +2787,8 @@ the plugin name does not begin with C. if $plugin->isa( 'Catalyst::Component' ); $proto->_plugins->{$plugin} = 1; unless ($instant) { - no strict 'refs'; - if ( my $meta = Class::MOP::get_metaclass_by_name($class) ) { - my @superclasses = ($plugin, $meta->superclasses ); - $meta->superclasses(@superclasses); - } else { - unshift @{"$class\::ISA"}, $plugin; - } + my $meta = Class::MOP::get_metaclass_by_name($class); + $meta->superclasses($plugin, $meta->superclasses); } return $class; }