X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FLog.pm;h=616a67833f1681ffceef516d04451e3171fe4a55;hb=1dc8af447f43168c875c0c62f2cfb50d66173eaf;hp=de7a447afc3a5ea8afca8f584fc40b4320638201;hpb=adee716c5ee8cda002acdaaa31764b72382101a3;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Log.pm b/lib/Catalyst/Log.pm index de7a447..616a678 100644 --- a/lib/Catalyst/Log.pm +++ b/lib/Catalyst/Log.pm @@ -2,7 +2,7 @@ package Catalyst::Log; use strict; use base 'Class::Accessor::Fast'; -use Data::Dumper; +use Data::Dump; our %LEVELS = (); @@ -62,17 +62,14 @@ sub disable { sub _dump { my $self = shift; - local $Data::Dumper::Terse = 1; - $self->info( Dumper( @_ ) ); + $self->info( Data::Dump::dump(@_) ); } sub _log { my $self = shift; my $level = shift; - my $time = localtime(time); my $message = join( "\n", @_ ); - $self->{body} .= - sprintf( "[%s] [catalyst] [%s] %s\n", $time, $level, $message ); + $self->{body} .= sprintf( "[%s] %s\n", $level, $message ); } sub _flush { @@ -124,6 +121,15 @@ e.g.: $c->log( MyLogger->new ); Your logging object is expected to provide the interface described here. +Good alternatives to consider are Log::Log4Perl and Log::Dispatch. + +If you want to be able to log arbitrary warnings, you can do something along +the lines of + + $SIG{__WARN__} = sub { MyApp->log->warn(@_); }; + +however this is (a) global, (b) hairy and (c) may have unexpected side effects. +Don't say we didn't warn you. =head1 LOG LEVELS