X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst.pm;h=f504e0cb04e41cb5ae1249c58957e1bd88016578;hp=a628d53cf8200577fd85bc0d9bae0cd6b031b77d;hb=8eae92ad64136956fabed844f64c3da865556bea;hpb=05d79b223fd5c1594a492fc05faca548e66478d9 diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index a628d53..f504e0c 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -1,7 +1,7 @@ package Catalyst; use Moose; -extends 'Catalyst::Component', 'Class::Accessor::Fast'; +extends 'Catalyst::Component'; use Moose::Util qw/find_meta/; use bytes; use Scope::Upper (); @@ -527,7 +527,7 @@ sub _comp_search_prefixes { if( @result ) { # Disgusting hack to work out correct method name my $warn_for = lc $prefixes[0]; - my $msg = "Used regexp fallback for \$c->{$warn_for}('${name}'), which found '" . + my $msg = "Used regexp fallback for \$c->${warn_for}('${name}'), which found '" . (join '", "', @result) . "'. Relying on regexp fallback behavior for " . "component resolution is unreliable and unsafe."; my $short = $result[0]; @@ -877,11 +877,11 @@ You can enable debug mode in several ways: =item The -Debug option in your MyApp.pm -=item By declaring "sub debug { 1 }" in your MyApp.pm. +=item By declaring C in your MyApp.pm. =back -Calling $c->debug(1) has no effect. +Calling C<< $c->debug(1) >> has no effect. =cut @@ -2398,14 +2398,19 @@ sub setup_log { $levels ||= ''; $levels =~ s/^\s+//; $levels =~ s/\s+$//; - my %levels = map { $_ => 1 } split /\s*,\s*/, $levels || ''; - + my %levels = map { $_ => 1 } split /\s*,\s*/, $levels; + + my $env_debug = Catalyst::Utils::env_value( $class, 'DEBUG' ); + if ( defined $env_debug ) { + $levels{debug} = 1 if $env_debug; # Ugly! + delete($levels{debug}) unless $env_debug; + } + unless ( $class->log ) { $class->log( Catalyst::Log->new(keys %levels) ); } - my $env_debug = Catalyst::Utils::env_value( $class, 'DEBUG' ); - if ( defined($env_debug) or $levels{debug} ) { + if ( $levels{debug} ) { Class::MOP::get_metaclass_by_name($class)->add_method('debug' => sub { 1 }); $class->log->debug('Debug messages enabled'); } @@ -2514,8 +2519,8 @@ Returns 1 when stats collection is enabled. Stats collection is enabled when the -Stats options is set, debug is on or when the _STATS environment variable is set. -Note that this is a static method, not an accessor and should be overloaded -by declaring "sub use_stats { 1 }" in your MyApp.pm, not by calling $c->use_stats(1). +Note that this is a static method, not an accessor and should be overridden +by declaring C in your MyApp.pm, not by calling C<< $c->use_stats(1) >>. =cut