X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FLog.pm;h=6bb131a98eee3ff026eac3bd0cbd0775b1b7b621;hb=a554cc3b4596813069727afe60e8e6cb2e701eeb;hp=af779bedce78fc5b1c8388cf76a792bfdbdc8360;hpb=b22c66686d892bba76a150f727561f8778f3ea72;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Log.pm b/lib/Catalyst/Log.pm index af779be..6bb131a 100644 --- a/lib/Catalyst/Log.pm +++ b/lib/Catalyst/Log.pm @@ -12,62 +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.: -=head1 METHODS + $c->log( MyLogger->new ); -=over 4 +Your logging object is expected to provide the interface described here. -=item $c->debug($msg) - -Logs a debugging message. -=cut +=head1 METHODS -sub debug { _format( 'debug', $_[1] ) } +=over 4 -=item $c->dump($ref) +=item $log->debug(@message) -Logs a formatted dump of a variable passed by reference (uses C). +Logs a debugging message. =cut -sub dump { _format( 'dump', Dumper( $_[1] ) ) } +sub debug { shift->_format( 'debug', @_ ) } -=item $c->error($msg) +=item $log->error(@message) Logs an error message. =cut -sub error { _format( 'error', $_[1] ) } +sub error { shift->_format( 'error', @_ ) } -=item $c->info($msg) +=item $log->info(@message) Logs an informational message. =cut -sub info { _format( 'info', $_[1] ) } +sub info { shift->_format( 'info', @_ ) } -=item $c->warn($msg) +=item $log->warn(@message) 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( $_[1] ) ) } + +=back + =head1 SEE ALSO L.