X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FLog.pm;h=c1ba85a0eebf0e3513f30eaaac236487a9020b1d;hp=01ff75f603a46e27b63443e34a01fa64067e3876;hb=e5ecd5bc38bac3e2fcfaf643ea2a4c6ab46d7e57;hpb=7fa2c9c1b85c98786655ad5169708d8dc84e8353 diff --git a/lib/Catalyst/Log.pm b/lib/Catalyst/Log.pm index 01ff75f..c1ba85a 100644 --- a/lib/Catalyst/Log.pm +++ b/lib/Catalyst/Log.pm @@ -1,21 +1,14 @@ package Catalyst::Log; -use strict; -#use base 'Class::Accessor::Fast'; +use Moose; use Data::Dump; our %LEVELS = (); -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 ]; @@ -43,12 +36,13 @@ has abort => (is => 'rw'); } } -sub new { +around new => sub { + my $orig = shift; my $class = shift; - my $self = $class->SUPER::new; + my $self = $class->$orig; $self->levels( scalar(@_) ? @_ : keys %LEVELS ); return $self; -} +}; sub levels { my ( $self, @levels ) = @_; @@ -221,8 +215,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: @@ -256,4 +250,6 @@ it under the same terms as Perl itself. =cut +__PACKAGE__->meta->make_immutable; + 1;