relative forwards call every matching private method!
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Log.pm
CommitLineData
fc7ec1d9 1package Catalyst::Log;
2
3use strict;
4use base 'Class::Accessor::Fast';
9b2bc37b 5use Data::Dumper;
6
7$Data::Dumper::Terse = 1;
fc7ec1d9 8
9=head1 NAME
10
11Catalyst::Log - Catalyst Log Class
12
13=head1 SYNOPSIS
14
82d2fcbe 15 $log = $c->log;
1db849bc 16 $log->debug(@message);
17 $log->error(@message);
18 $log->info(@message);
19 $log->warn(@message);
82d2fcbe 20
fc7ec1d9 21See L<Catalyst>.
22
23=head1 DESCRIPTION
24
82d2fcbe 25This module provides the default, simple logging functionality for Catalyst.
26If you want something different set C<$c->log> in your application module, e.g.:
27
28 $c->log( MyLogger->new );
29
30Your logging object is expected to provide the interface described here.
31
fc7ec1d9 32
b22c6668 33=head1 METHODS
fc7ec1d9 34
b22c6668 35=over 4
fc7ec1d9 36
1db849bc 37=item $log->debug(@message)
b22c6668 38
39Logs a debugging message.
fc7ec1d9 40
41=cut
42
1db849bc 43sub debug { shift->_format( 'debug', @_ ) }
fc7ec1d9 44
1db849bc 45=item $log->error(@message)
fc7ec1d9 46
b22c6668 47Logs an error message.
fc7ec1d9 48
49=cut
50
1db849bc 51sub error { shift->_format( 'error', @_ ) }
fc7ec1d9 52
1db849bc 53=item $log->info(@message)
fc7ec1d9 54
b22c6668 55Logs an informational message.
fc7ec1d9 56
57=cut
58
1db849bc 59sub info { shift->_format( 'info', @_ ) }
fc7ec1d9 60
1db849bc 61=item $log->warn(@message)
fc7ec1d9 62
b22c6668 63Logs a warning message.
fc7ec1d9 64
65=cut
66
1db849bc 67sub warn { shift->_format( 'warn', @_ ) }
fc7ec1d9 68
69sub _format {
1db849bc 70 my $class = shift;
71 my $level = shift;
72 my $time = localtime(time);
73 my $message = join( "\n", @_ );
74 printf( STDERR "[%s] [catalyst] [%s] %s\n", $time, $level, $message );
fc7ec1d9 75}
76
b22c6668 77=back
78
c9afa5fc 79=head1 DEPRECATED METHODS
80
81=over 4
82
83=item $log->dump($reference)
84
85Logs a Data::Dumper of reference.
86
87=cut
88
b333ca6b 89sub dump { shift->_format( 'dump', Dumper( $_[0] ) ) }
c9afa5fc 90
91=back
92
fc7ec1d9 93=head1 SEE ALSO
94
95L<Catalyst>.
96
97=head1 AUTHOR
98
99Sebastian Riedel, C<sri@cpan.org>
100
101=head1 COPYRIGHT
102
103This program is free software, you can redistribute it and/or modify it under
104the same terms as Perl itself.
105
106=cut
107
1081;