From: Rafael Kitover Date: Thu, 23 Apr 2009 00:45:06 +0000 (+0000) Subject: runtime: fix logging with -Debug X-Git-Tag: 5.80003~39 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=e24229207cb1369e0c4ad27a3261effe20d986a8 runtime: fix logging with -Debug --- diff --git a/lib/Catalyst/Log.pm b/lib/Catalyst/Log.pm index a28c373..80e7182 100644 --- a/lib/Catalyst/Log.pm +++ b/lib/Catalyst/Log.pm @@ -42,7 +42,13 @@ around new => sub { my $orig = shift; my $class = shift; my $self = $class->$orig; - $self->levels( scalar(@_) ? @_ : keys %LEVELS ); + + if (@_ == 1 && $_[0] eq 'debug') { + $self->levels( keys %LEVELS ); + } else { + $self->levels( scalar(@_) ? @_ : keys %LEVELS ); + } + return $self; }; diff --git a/t/unit_core_setup.t b/t/unit_core_setup.t index bcf3030..a319007 100644 --- a/t/unit_core_setup.t +++ b/t/unit_core_setup.t @@ -31,10 +31,10 @@ sub build_test_app_with_setup { ok my $c = MyTestDebug->new, 'Get debug app object'; ok my $log = $c->log, 'Get log object'; isa_ok $log, 'Catalyst::Log', 'It should be a Catalyst::Log object'; - ok !$log->is_warn, 'Warnings should be disabled'; - ok !$log->is_error, 'Errors should be disabled'; - ok !$log->is_fatal, 'Fatal errors should be disabled'; - ok !$log->is_info, 'Info should be disabled'; + ok $log->is_warn, 'Warnings should be enabled'; + ok $log->is_error, 'Errors should be enabled'; + ok $log->is_fatal, 'Fatal errors should be enabled'; + ok $log->is_info, 'Info should be enabled'; ok $log->is_debug, 'Debugging should be enabled'; ok $app->debug, 'debug method should return true'; } diff --git a/t/unit_core_setup_log.t b/t/unit_core_setup_log.t index ffb2859..843d10e 100644 --- a/t/unit_core_setup_log.t +++ b/t/unit_core_setup_log.t @@ -49,10 +49,10 @@ local %ENV; # Ensure blank or someone, somewhere will fail.. $app->setup_log(''); ok $app->debug, 'In debug mode'; test_log_object($app->log, - fatal => 0, - error => 0, - warn => 0, - info => 0, + fatal => 1, + error => 1, + warn => 1, + info => 1, debug => 1, ); } @@ -89,10 +89,10 @@ local %ENV; # Ensure blank or someone, somewhere will fail.. $app->setup_log('debug'); ok $app->debug, 'In debug mode'; test_log_object($app->log, - fatal => 0, - error => 0, - warn => 0, - info => 0, + fatal => 1, + error => 1, + warn => 1, + info => 1, debug => 1, ); }