tokuhirom's Blog

Log::Pony::Emotional もつくってみた

ref. http://d.hatena.ne.jp/hirose31/20130215/1360908384

継承でかけるので楽。

package Log::Pony::Emotional;
use parent qw(Log::Pony);


our $EMOTION = {
    DEBUG    => '(☼ Д ☼)',
    INFO     => 'm9(^Д^)',
    WARN     => '(´・ω・`)',
    CRITICAL => '(; Д ) ゜ ゜',
};

sub process {
    my ( $self, $level, $message ) = @_;
    my $time  = $self->time();
    my $trace = $self->trace_info();
    if ( $self->color ) {
        $message = $self->colorize( $level, $message );
    }
    my $emotion = $EMOTION->{$level};
    print STDERR "$time $emotion [$level] $message $trace\n";
}