[Catalyst-commits] r9782 - in Catalyst-Runtime/5.80/trunk: lib t
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Tue Apr 21 21:56:20 GMT 2009
Author: t0m
Date: 2009-04-21 22:56:20 +0100 (Tue, 21 Apr 2009)
New Revision: 9782
Modified:
Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
Catalyst-Runtime/5.80/trunk/t/unit_core_setup_log.t
Log:
Fix kds bug, find another bug causing all log levels to be turned on when passing C::Log an empty string
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm 2009-04-21 21:38:02 UTC (rev 9781)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm 2009-04-21 21:56:20 UTC (rev 9782)
@@ -2398,14 +2398,19 @@
$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');
}
Modified: Catalyst-Runtime/5.80/trunk/t/unit_core_setup_log.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/unit_core_setup_log.t 2009-04-21 21:38:02 UTC (rev 9781)
+++ Catalyst-Runtime/5.80/trunk/t/unit_core_setup_log.t 2009-04-21 21:56:20 UTC (rev 9782)
@@ -1,13 +1,14 @@
use strict;
use warnings;
-use Test::More tests => 24;
+use Test::More tests => 30;
use Test::Exception;
use Catalyst ();
sub mock_app {
my $name = shift;
+ warn("Setting up mock application: $name\n");
my $meta = Moose->init_meta( for_class => $name );
$meta->superclasses('Catalyst');
return $meta->name;
@@ -48,16 +49,28 @@
$app->setup_log('');
ok $app->debug, 'In debug mode';
test_log_object($app->log,
- fatal => 1, # Note, log levels _are_ seemingly additive if debug is on.
- error => 1, # CRACK - someone has been smoking it.
- warn => 1,
- info => 1,
+ fatal => 0,
+ error => 0,
+ warn => 0,
+ info => 0,
debug => 1,
);
}
{
local %ENV = ( CATALYST_DEBUG => 0 );
my $app = mock_app('TestLogAppDebugEnvUnset');
+ $app->setup_log('warn');
+ ok !$app->debug, 'Not In debug mode';
+ test_log_object($app->log,
+ fatal => 0,
+ error => 0,
+ warn => 1,
+ info => 0,
+ debug => 0,
+ );
+}
+{
+ my $app = mock_app('TestLogAppEmptyString');
$app->setup_log('');
ok !$app->debug, 'Not In debug mode';
test_log_object($app->log,
More information about the Catalyst-commits
mailing list