X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FLog.pm;h=6bb131a98eee3ff026eac3bd0cbd0775b1b7b621;hb=a554cc3b4596813069727afe60e8e6cb2e701eeb;hp=087789fcb2b5eaf718bd1bbb8c023a2cbc2e0a35;hpb=82d2fcbe3abcfcc422639d2e557ffbff0f8f062f;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Log.pm b/lib/Catalyst/Log.pm index 087789f..6bb131a 100644 --- a/lib/Catalyst/Log.pm +++ b/lib/Catalyst/Log.pm @@ -13,11 +13,10 @@ Catalyst::Log - Catalyst Log Class =head1 SYNOPSIS $log = $c->log; - $log->debug($msg, @args); - $log->dump($ref); - $log->error($msg, @args); - $log->info($msg, @args); - $log->warn($msg, @args); + $log->debug(@message); + $log->error(@message); + $log->info(@message); + $log->warn(@message); See L. @@ -35,57 +34,62 @@ Your logging object is expected to provide the interface described here. =over 4 -=item $log->debug($msg, @args) +=item $log->debug(@message) Logs a debugging message. =cut -sub debug { _format( 'debug', splice(@_, 1) ) } +sub debug { shift->_format( 'debug', @_ ) } -=item $log->dump($ref) - -Logs a formatted dump of a variable passed by reference (uses C). - -=cut - -sub dump { _format( 'dump', Dumper( $_[1] ) ) } - -=item $log->error($msg, @args) +=item $log->error(@message) Logs an error message. =cut -sub error { _format( 'error', splice(@_, 1) ) } +sub error { shift->_format( 'error', @_ ) } -=item $log->info($msg, @args) +=item $log->info(@message) Logs an informational message. =cut -sub info { _format( 'info', splice(@_, 1) ) } +sub info { shift->_format( 'info', @_ ) } -=item $log->warn($msg, @args) +=item $log->warn(@message) Logs a warning message. =cut -sub warn { _format( 'warn', splice(@_, 1) ) } +sub warn { shift->_format( 'warn', @_ ) } sub _format { - if (@_ > 2) { - printf STDERR '[' . localtime(time) . "] [catalyst] [$_[0]] $_[1]\n", splice(@_, 2); - } - else { - print STDERR '[' . localtime(time) . "] [catalyst] [$_[0]] $_[1]\n"; - } + my $class = shift; + my $level = shift; + my $time = localtime(time); + my $message = join( "\n", @_ ); + printf( STDERR "[%s] [catalyst] [%s] %s\n", $time, $level, $message ); } =back +=head1 DEPRECATED METHODS + +=over 4 + +=item $log->dump($reference) + +Logs a Data::Dumper of reference. + +=cut + +sub dump { shift->_format( 'dump', Dumper( $_[1] ) ) } + +=back + =head1 SEE ALSO L.