Catalyst::Plugin::Log::Colorful - Catalyst Plugin for Colorful Log
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
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'.
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 );
Catalyst::Log Term::ANSIColor
Tomohiro Teranishi <tomohiro.teranishi@gmail.com>
To install Catalyst::Plugin::Log::Colorful, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::Plugin::Log::Colorful
CPAN shell
perl -MCPAN -e shell install Catalyst::Plugin::Log::Colorful
For more information on module installation, please visit the detailed CPAN module installation guide.