X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FLog.pm;h=833087bebb67170ce3f67c53635aa88fc7e91d82;hb=1927c219b552ac80dff59c235a51d422ac5b9d25;hp=7ae9f0720fb48bc70da0fb0424620b622709c440;hpb=fc7ec1d96ee55d1bf42af3abce155ecb717b9e2b;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Log.pm b/lib/Catalyst/Log.pm index 7ae9f07..833087b 100644 --- a/lib/Catalyst/Log.pm +++ b/lib/Catalyst/Log.pm @@ -2,6 +2,9 @@ package Catalyst::Log; use strict; use base 'Class::Accessor::Fast'; +use Data::Dumper; + +$Data::Dumper::Terse = 1; =head1 NAME @@ -9,50 +12,84 @@ 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.: + + $c->log( MyLogger->new ); + +Your logging object is expected to provide the interface described here. -=head2 METHODS -=head3 debug +=head1 METHODS -Log debug informations. +=over 4 + +=item $log->debug(@message) + +Logs a debugging message. =cut -sub debug { _format( 'debug', $_[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 + +=head1 DEPRECATED METHODS + +=over 4 + +=item $log->dump($reference) + +Logs a Data::Dumper of reference. + +=cut + +sub dump { shift->_format( 'dump', Dumper( $_[0] ) ) } + +=back + =head1 SEE ALSO L.