Log::Any::Plugin::ANSIColor - Auto-colorize Log::Any logs with Term::ANSIColor
use Log::Any::Adapter 'Stderr'; # Choose any adapter that makes sense use Log::Any::Plugin; Log::Any::Plugin->add('ANSIColor'); # Use the default colorscheme # In this or any other module use Log::Any qw( $log ); $log->alert('Call the police!'); # Prints as red on white
Log::Any::Plugin::ANSIColor automatically applies ANSI colors to log messages depending on the log level.
For example, with the default colorscheme, error logs are red, warning logs are yellow.
error
warning
If a given log level has no coloring, the original log method is left intact, and incurs no overhead.
Adding the plugin with no extra arguments gives the default colorscheme.
Log::Any::Plugin->add('ANSIColor');
Note that info and notice messages have no special coloring in the default colorscheme.
info
notice
Specify some colors to completely replace the default colorscheme. Only the specified colors are applied.
Log::Any::Plugin->add('ANSIColor', error => 'white on_red', warning => 'black on_yellow', );
Use default => 1 to include the default colorscheme with customisations. Default colors can be switched off by specifying 'none' as the color.
default => 1
'none'
Log::Any::Plugin->add('ANSIColor', default => 1, # use default colors error => 'white on_red', # override error color warning => 'none', # turn off warning color );
Valid colors are any strings acceptable to colored in Term::ANSIColor. eg. 'blue' 'bright_red on_white
colored
'blue'
'bright_red on_white
Copyright (C) Stephen Thirlwall.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Stephen Thirlwall <sdt@cpan.org>
To install Log::Any::Plugin::ANSIColor, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Log::Any::Plugin::ANSIColor
CPAN shell
perl -MCPAN -e shell install Log::Any::Plugin::ANSIColor
For more information on module installation, please visit the detailed CPAN module installation guide.