X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FLog.pm;h=f2a6aee5aca243690f171ce3cdfb80804257eee0;hb=a268a0112398ac10d8fabd86ed28a183cbe4398e;hp=087789fcb2b5eaf718bd1bbb8c023a2cbc2e0a35;hpb=82d2fcbe3abcfcc422639d2e557ffbff0f8f062f;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Log.pm b/lib/Catalyst/Log.pm index 087789f..f2a6aee 100644 --- a/lib/Catalyst/Log.pm +++ b/lib/Catalyst/Log.pm @@ -13,18 +13,19 @@ 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. =head1 DESCRIPTION -This module provides the default, simple logging functionality for Catalyst. -If you want something different set C<$c->log> in your application module, e.g.: +This module provides the default, simple logging functionality for +Catalyst. +If you want something different set C<$c->log> in your application +module, e.g.: $c->log( MyLogger->new ); @@ -35,57 +36,54 @@ 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 +=cut + +# Private - Logs a Data::Dumper of reference. +sub _dump { shift->_format( 'dump', Dumper( $_[0] ) ) } + + =head1 SEE ALSO L. @@ -93,11 +91,12 @@ L. =head1 AUTHOR Sebastian Riedel, C +Marcus Ramberg, C =head1 COPYRIGHT -This program is free software, you can redistribute it and/or modify it under -the same terms as Perl itself. +This program is free software, you can redistribute it and/or modify +it under the same terms as Perl itself. =cut