bye bye Class::C3. for good.
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Log.pm
index c1ba85a..e1953b2 100644 (file)
@@ -6,12 +6,13 @@ use Data::Dump;
 our %LEVELS = ();
 
 has level => (is => 'rw');
-has _body  => (is => 'rw');
+has _body => (is => 'rw');
 has abort => (is => 'rw');
 
 {
     my @levels = qw[ debug info warn error fatal ];
 
+    my $meta = __PACKAGE__->meta;
     for ( my $i = 0 ; $i < @levels ; $i++ ) {
 
         my $name  = $levels[$i];
@@ -19,20 +20,18 @@ has abort => (is => 'rw');
 
         $LEVELS{$name} = $level;
 
-        no strict 'refs';
-
-        *{$name} = sub {
+       $meta->add_method($name, sub {
             my $self = shift;
 
             if ( $self->level & $level ) {
                 $self->_log( $name, @_ );
             }
-        };
+        });
 
-        *{"is_$name"} = sub {
+        $meta->add_method("is_$name", sub {
             my $self = shift;
             return $self->level & $level;
-        };
+        });;
     }
 }
 
@@ -99,6 +98,9 @@ sub _send_to_log {
     print STDERR @_;
 }
 
+no Moose;
+__PACKAGE__->meta->make_immutable();
+
 1;
 
 __END__
@@ -215,8 +217,8 @@ Is the log level active?
 
 =head2 abort
 
-Should Catalyst emit logs for this request? Will be reset at the end of
-each request.
+Should Catalyst emit logs for this request? Will be reset at the end of 
+each request. 
 
 *NOTE* This method is not compatible with other log apis, so if you plan
 to use Log4Perl or another logger, you should call it like this: