[Catalyst-commits] r7506 - Catalyst-Runtime/5.80/branches/moose/lib/Catalyst

groditi at dev.catalyst.perl.org groditi at dev.catalyst.perl.org
Sat Mar 15 05:21:42 GMT 2008


Author: groditi
Date: 2008-03-15 05:21:42 +0000 (Sat, 15 Mar 2008)
New Revision: 7506

Modified:
   Catalyst-Runtime/5.80/branches/moose/lib/Catalyst/Exception.pm
   Catalyst-Runtime/5.80/branches/moose/lib/Catalyst/Log.pm
Log:
reapplying changes by konobi that I accidentally undid earlier. sorry about that

Modified: Catalyst-Runtime/5.80/branches/moose/lib/Catalyst/Exception.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/moose/lib/Catalyst/Exception.pm	2008-03-15 05:12:50 UTC (rev 7505)
+++ Catalyst-Runtime/5.80/branches/moose/lib/Catalyst/Exception.pm	2008-03-15 05:21:42 UTC (rev 7506)
@@ -1,15 +1,10 @@
 package Catalyst::Exception;
 
-use strict;
-use vars qw[@ISA $CATALYST_EXCEPTION_CLASS];
+# XXX: See bottom of file for Exception implementation
 
-BEGIN {
-    push( @ISA, $CATALYST_EXCEPTION_CLASS || 'Catalyst::Exception::Base' );
-}
-
 package Catalyst::Exception::Base;
 
-use strict;
+use Moose;
 use Carp ();
 
 =head1 NAME
@@ -49,6 +44,10 @@
     Carp::croak($message);
 }
 
+=head2 meta
+
+Provided by Moose
+
 =head1 AUTHOR
 
 Sebastian Riedel, C<sri at cpan.org>
@@ -61,4 +60,13 @@
 
 =cut
 
+package Catalyst::Exception;
+
+use Moose;
+use vars qw[$CATALYST_EXCEPTION_CLASS];
+
+BEGIN {
+    extends($CATALYST_EXCEPTION_CLASS || 'Catalyst::Exception::Base');
+}
+
 1;

Modified: Catalyst-Runtime/5.80/branches/moose/lib/Catalyst/Log.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/moose/lib/Catalyst/Log.pm	2008-03-15 05:12:50 UTC (rev 7505)
+++ Catalyst-Runtime/5.80/branches/moose/lib/Catalyst/Log.pm	2008-03-15 05:21:42 UTC (rev 7506)
@@ -1,15 +1,21 @@
 package Catalyst::Log;
 
 use strict;
-use base 'Class::Accessor::Fast';
+#use base 'Class::Accessor::Fast';
 use Data::Dump;
 
 our %LEVELS = ();
 
-__PACKAGE__->mk_accessors('level');
-__PACKAGE__->mk_accessors('body');
-__PACKAGE__->mk_accessors('abort');
+use Moose;
 
+has level => (is => 'rw');
+has _body  => (is => 'rw');
+has abort => (is => 'rw');
+
+#__PACKAGE__->mk_accessors('level');
+#__PACKAGE__->mk_accessors('body');
+#__PACKAGE__->mk_accessors('abort');
+
 {
     my @levels = qw[ debug info warn error fatal ];
 
@@ -25,14 +31,14 @@
         *{$name} = sub {
             my $self = shift;
 
-            if ( $self->{level} & $level ) {
+            if ( $self->level & $level ) {
                 $self->_log( $name, @_ );
             }
         };
 
         *{"is_$name"} = sub {
             my $self = shift;
-            return $self->{level} & $level;
+            return $self->level & $level;
         };
     }
 }
@@ -52,12 +58,20 @@
 
 sub enable {
     my ( $self, @levels ) = @_;
-    $self->{level} |= $_ for map { $LEVELS{$_} } @levels;
+    my $level = $self->level;
+    for(map { $LEVELS{$_} } @levels){
+      $level |= $_;
+    }
+    $self->level($level);
 }
 
 sub disable {
     my ( $self, @levels ) = @_;
-    $self->{level} &= ~$_ for map { $LEVELS{$_} } @levels;
+    my $level = $self->level;
+    for(map { $LEVELS{$_} } @levels){
+      $level &= ~$_;
+    }
+    $self->level($level);
 }
 
 sub _dump {
@@ -70,18 +84,20 @@
     my $level   = shift;
     my $message = join( "\n", @_ );
     $message .= "\n" unless $message =~ /\n$/;
-    $self->{body} .= sprintf( "[%s] %s", $level, $message );
+    my $body = $self->_body;
+    $body .= sprintf( "[%s] %s", $level, $message );
+    $self->_body($body);
 }
 
 sub _flush {
     my $self = shift;
-    if ( $self->abort || !$self->body ) {
+    if ( $self->abort || !$self->_body ) {
         $self->abort(undef);
     }
     else {
-        $self->_send_to_log( $self->body );
+        $self->_send_to_log( $self->_body );
     }
-    $self->body(undef);
+    $self->_body(undef);
 }
 
 sub _send_to_log {
@@ -169,6 +185,10 @@
     $log = Catalyst::Log->new;
     $log = Catalyst::Log->new( 'warn', 'error' );
 
+=head2 level
+
+Contains a bitmask of the currently set log levels.
+
 =head2 levels
 
 Set log levels
@@ -217,6 +237,8 @@
 You may subclass this module and override this method to get finer control
 over the log output.
 
+=head2 meta
+
 =head1 SEE ALSO
 
 L<Catalyst>.




More information about the Catalyst-commits mailing list