[Catalyst-commits] r8993 - in Catalyst-Runtime/5.80/trunk: lib t
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Fri Jan 2 23:13:37 GMT 2009
Author: t0m
Date: 2009-01-02 23:13:36 +0000 (Fri, 02 Jan 2009)
New Revision: 8993
Modified:
Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
Catalyst-Runtime/5.80/trunk/t/unit_core_setup.t
Log:
Fix additive logging setup, and ergo Catalyst-Plugin-Devel-ModuleVersions
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm 2009-01-02 22:42:14 UTC (rev 8992)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm 2009-01-02 23:13:36 UTC (rev 8993)
@@ -2226,19 +2226,19 @@
Note that if the log has already been setup, by either a previous call to
C<setup_log> or by a call such as C<< __PACKAGE__->log( MyLogger->new ) >>,
-that this method won't actually set up the log.
+that this method won't actually set up the log object.
=cut
sub setup_log {
my ( $class, $levels ) = @_;
- my %levels;
+ $levels ||= '';
+ $levels =~ s/^\s+//;
+ $levels =~ s/\s+$//;
+ my %levels = map { $_ => 1 } split /\s*,\s*/, $levels || '';
+
unless ( $class->log ) {
- $levels ||= '';
- $levels =~ s/^\s+//;
- $levels =~ s/\s+$//;
- %levels = map { $_ => 1 } split /\s*,\s*/, $levels || '';
$class->log( Catalyst::Log->new(keys %levels) );
}
Modified: Catalyst-Runtime/5.80/trunk/t/unit_core_setup.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/unit_core_setup.t 2009-01-02 22:42:14 UTC (rev 8992)
+++ Catalyst-Runtime/5.80/trunk/t/unit_core_setup.t 2009-01-02 23:13:36 UTC (rev 8993)
@@ -2,7 +2,7 @@
use warnings;
use Catalyst::Runtime;
-use Test::More tests => 18;
+use Test::More tests => 20;
{
# Silence the log.
@@ -46,3 +46,16 @@
ok $log->is_fatal, 'Fatal errors should be enabled';
ok !$log->is_info, 'Info should be disabled';
ok !$log->is_debug, 'Debugging should be disabled';
+
+TESTOWNLOGGER: {
+ package MyTestAppWithOwnLogger;
+ use base qw/Catalyst/;
+ use Test::MockObject;
+ my $log = Test::MockObject->new;
+ $log->set_false(qw/debug error fatal info warn/);
+ __PACKAGE__->log($log);
+ __PACKAGE__->setup('-Debug');
+}
+
+ok $c = MyTestAppWithOwnLogger->new, 'Get with own logger app object';
+ok $c->debug, '$c->debug is true';
More information about the Catalyst-commits
mailing list