X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FLog.pm;h=55570662ceec68c613dabda801334111493b632b;hb=9992a5990019714a7272a6b656acae25d95e46c3;hp=c1ba85a0eebf0e3513f30eaaac236487a9020b1d;hpb=e5ecd5bc38bac3e2fcfaf643ea2a4c6ab46d7e57;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Log.pm b/lib/Catalyst/Log.pm index c1ba85a..5557066 100644 --- a/lib/Catalyst/Log.pm +++ b/lib/Catalyst/Log.pm @@ -1,17 +1,21 @@ package Catalyst::Log; use Moose; +with 'MooseX::Emulate::Class::Accessor::Fast'; + use Data::Dump; +use Class::MOP (); 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 = Class::MOP::get_metaclass_by_name(__PACKAGE__); for ( my $i = 0 ; $i < @levels ; $i++ ) { my $name = $levels[$i]; @@ -19,20 +23,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 +101,9 @@ sub _send_to_log { print STDERR @_; } +no Moose; +__PACKAGE__->meta->make_immutable(); + 1; __END__ @@ -215,8 +220,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: @@ -237,11 +242,9 @@ over the log output. L. -=head1 AUTHOR +=head1 AUTHORS -Sebastian Riedel, C -Marcus Ramberg, C -Christian Hansen, C +Catalyst Contributors, see Catalyst.pm =head1 COPYRIGHT