X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FLog.pm;h=f2a6aee5aca243690f171ce3cdfb80804257eee0;hb=6d1ab9154b299ce3697ec69d4ffd10dda4c07c0e;hp=d7776f3c3742372ba5f1361daebc552d0cdb3b39;hpb=9b2bc37b4bcee56036419a392d922f053a130420;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Log.pm b/lib/Catalyst/Log.pm index d7776f3..f2a6aee 100644 --- a/lib/Catalyst/Log.pm +++ b/lib/Catalyst/Log.pm @@ -12,58 +12,78 @@ Catalyst::Log - Catalyst Log Class =head1 SYNOPSIS + $log = $c->log; + $log->debug(@message); + $log->error(@message); + $log->info(@message); + $log->warn(@message); + See L. =head1 DESCRIPTION -Simple logging functionality for Catalyst. +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.: -=head2 METHODS + $c->log( MyLogger->new ); -=head3 debug +Your logging object is expected to provide the interface described here. -Log debug informations. -=cut +=head1 METHODS -sub debug { _format( 'debug', $_[1] ) } +=over 4 -=head3 dump +=item $log->debug(@message) -Dump stuff. +Logs a debugging message. =cut -sub dump { _format( 'dump', Dumper( $_[1] ) ) } +sub debug { shift->_format( 'debug', @_ ) } -=head3 error +=item $log->error(@message) -Log error informations. +Logs an error message. =cut -sub error { _format( 'error', $_[1] ) } +sub error { shift->_format( 'error', @_ ) } -=head3 info +=item $log->info(@message) -Log informations. +Logs an informational message. =cut -sub info { _format( 'info', $_[1] ) } +sub info { shift->_format( 'info', @_ ) } -=head3 warn +=item $log->warn(@message) -Log warnings. +Logs a warning message. =cut -sub warn { _format( 'warn', $_[1] ) } +sub warn { shift->_format( 'warn', @_ ) } sub _format { - 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. @@ -71,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