NAME
Catalyst::Plugin::Log::Colorful - Catalyst Plugin for Colorful Log
SYNOPSIS
sub foo : Private {
my ($self , $c ) = @_;
$c->log->debug('debug');
$c->log->info( 'info');
$c->log->warn( 'warn');
$c->log->error('error');
$c->log->fatal('fatal');
$c->log->debug('debug' , 'red', 'white');
$c->log->warn( 'warn' , 'blue' );
}
myapp.yml # default color is set but can change.
'Plugin::Log::Colorful' :
color_table :
debug :
color : white
bg_color : blue
warn :
color : blue
bg_color : green
error :
color : red
bg_color : yellow
fatal :
color : red
bg_color : green
DESCRIPTION
Sometimes when I am monitoring 'tail -f error_log' or './script/my_server.pl' during develop phase, I could not find log message because of a lot of logs. This plugin may help to find it out. This plugin is using Term::ANSIColor.
Of course when you open log file with vi or some editor, the color wont change and also you will see additional log such as '[31;47moraora[0m'.
BACKWARD COMPATIBILITY
for new version I remove $c->log->color() but still you can use if you turn on on_backward_compatibility setting.
This plugin injects a color() method into the Catalyst::Log namespace.
use Catalyst qw/-Debug ConfigLoader Log::Colorful/;
__PACKAGE__->config(
name => 'MyApp' ,
'Plugin::Log::Colorful' => {
on_backward_compatibility => 1,
text => 'blue',
background => 'green',
}
);
In your controller.
$c->log->color('hello');
$c->log->color('hello blue' , 'blue');
$c->log->color('hello red on white' , 'red' , 'white');
$c->log->color( $hash_ref );
$c->log->color( $array_ref );
METHOD
setup
SEE ALSO
AUTHOR
Tomohiro Teranishi <tomohiro.teranishi@gmail.com>