1Catalyst::Log(3) User Contributed Perl Documentation Catalyst::Log(3)
2
3
4
6 Catalyst::Log - Catalyst Log Class
7
9 $log = $c->log;
10 $log->debug($message);
11 $log->info($message);
12 $log->warn($message);
13 $log->error($message);
14 $log->fatal($message);
15
16 if ( $log->is_debug ) {
17 # expensive debugging
18 }
19
20 See Catalyst.
21
23 This module provides the default, simple logging functionality for Cat‐
24 alyst. If you want something different set "$c->log" in your applica‐
25 tion module, e.g.:
26
27 $c->log( MyLogger->new );
28
29 Your logging object is expected to provide the interface described
30 here. Good alternatives to consider are Log::Log4Perl and Log::Dis‐
31 patch.
32
33 If you want to be able to log arbitrary warnings, you can do something
34 along the lines of
35
36 $SIG{__WARN__} = sub { MyApp->log->warn(@_); };
37
38 however this is (a) global, (b) hairy and (c) may have unexpected side
39 effects. Don't say we didn't warn you.
40
42 debug
43
44 $log->is_debug;
45 $log->debug($message);
46
47 info
48
49 $log->is_info;
50 $log->info($message);
51
52 warn
53
54 $log->is_warn;
55 $log->warn($message);
56
57 error
58
59 $log->is_error;
60 $log->error($message);
61
62 fatal
63
64 $log->is_fatal;
65 $log->fatal($message);
66
68 new
69
70 Constructor. Defaults to enable all levels unless levels are provided
71 in arguments.
72
73 $log = Catalyst::Log->new;
74 $log = Catalyst::Log->new( 'warn', 'error' );
75
76 levels
77
78 Set log levels
79
80 $log->levels( 'warn', 'error', 'fatal' );
81
82 enable
83
84 Enable log levels
85
86 $log->enable( 'warn', 'error' );
87
88 disable
89
90 Disable log levels
91
92 $log->disable( 'warn', 'error' );
93
94 is_debug
95
96 is_error
97
98 is_fatal
99
100 is_info
101
102 is_warn
103
104 Is the log level active?
105
106 abort
107
108 Should Catalyst emit logs for this request? Will be reset at the end of
109 each request.
110
111 *NOTE* This method is not compatible with other log apis, so if you
112 plan to use Log4Perl or another logger, you should call it like this:
113
114 $c->log->abort(1) if $c->log->can('abort');
115
116 _send_to_log
117
118 $log->_send_to_log( @messages );
119
120 This protected method is what actually sends the log information to
121 STDERR. You may subclass this module and override this method to get
122 finer control over the log output.
123
125 Catalyst.
126
128 Sebastian Riedel, "sri@cpan.org" Marcus Ramberg, "mramberg@cpan.org"
129 Christian Hansen, "ch@ngmedia.com"
130
132 This program is free software, you can redistribute it and/or modify it
133 under the same terms as Perl itself.
134
135
136
137perl v5.8.8 2007-09-20 Catalyst::Log(3)