Subject: | Unnecessary multiple $RESET sequences |
If foreground color and background color or bold is set, then multiple color reset sequences are printed, when only one would be sufficient. Example:
$ perl -MLog::Dispatch::Screen::Color -e '$log=Log::Dispatch::Screen::Color->new(min_level=>"debug"); $log->log(level=>"warning", message=>"test\n")' |& od -c
0000000 033 [ 4 3 m 033 [ 3 0 m t e s t \n 033
0000020 [ 0 m 033 [ 0 m
0000027
The reset sequence is 033 [ 0 m, which appears twice at the end. Only one would be enough.
sub colored could be rewritten like this (untested):
my $need_RESET;
if (my $name = $map->{text}) {
my $color = $COLOR_CACHE{$name} ||= Term::ANSIColor::color($name);
$message = join '', $color, $message;
$need_RESET = 1;
}
... (more similar changes) ...
if ($need_RESET) {
$message .= $RESET;
}