Catalyst::Log - Catalyst Log Class
$log = $c->log; $log->debug($message); $log->info($message); $log->warn($message); $log->error($message); $log->fatal($message); if ( $log->is_debug ) { # expensive debugging }
See Catalyst.
This module provides the default, simple logging functionality for Catalyst. If you want something different set $c->log in your application module, e.g.:
$c->log
$c->log( MyLogger->new );
Your logging object is expected to provide the interface described here. Good alternatives to consider are Log::Log4Perl and Log::Dispatch.
If you want to be able to log arbitrary warnings, you can do something along the lines of
$SIG{__WARN__} = sub { MyApp->log->warn(@_); };
however this is (a) global, (b) hairy and (c) may have unexpected side effects. Don't say we didn't warn you.
$log->is_debug; $log->debug($message);
$log->is_info; $log->info($message);
$log->is_warn; $log->warn($message);
$log->is_error; $log->error($message);
$log->is_fatal; $log->fatal($message);
Constructor. Defaults to enable all levels unless levels are provided in arguments.
$log = Catalyst::Log->new; $log = Catalyst::Log->new( 'warn', 'error' );
Contains a bitmask of the currently set log levels.
Set log levels
$log->levels( 'warn', 'error', 'fatal' );
Enable log levels
$log->enable( 'warn', 'error' );
Disable log levels
$log->disable( 'warn', 'error' );
Is the log level active?
Should Catalyst emit logs for this request? Will be reset at the end of each request.
*NOTE* This method is not compatible with other log apis, so if you plan to use Log4Perl or another logger, you should call it like this:
$c->log->abort(1) if $c->log->can('abort');
$log->_send_to_log( @messages );
This protected method is what actually sends the log information to STDERR. You may subclass this module and override this method to get finer control over the log output.
Catalyst.
Catalyst Contributors, see Catalyst.pm
This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
To install Catalyst::Runtime, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::Runtime
CPAN shell
perl -MCPAN -e shell install Catalyst::Runtime
For more information on module installation, please visit the detailed CPAN module installation guide.