Subject: | Log::Log4perl::Appender::ScreenColoredLevels no longer issues RESET |
Date: | Fri, 9 Aug 2013 16:01:55 -0700 |
To: | bug-Log-Log4perl [...] rt.cpan.org, bug-Term-ANSIColor [...] rt.cpan.org |
From: | Michael Hicks <nooneofconsequence [...] gmail.com> |
I think this is possibly due to a bug in Term::ANSIColor but I'm not sure.
I've noticed that if I'm using Log::Log4perl::Appender::ScreenColoredLevels as my appended and have normal perl print statements following a log4perl logger invocation, whatever color setting was used for the last log4perl print gets used for my standard print statement as well.
I see that in the patch from issue 30899 which replaced the prior way of using Term::ANSIColor qw(:constants) and actually specifying the RESET in the formatting like:
return GREEN . $message . RESET;
with the new way of using the Term::ANSIColor colored function like:
$msg = Term::ANSIColor::colored( $msg, $color );
from the documentation on Term::ANSIColor here: http://search.cpan.org/~rra/Term-ANSIColor-4.02/ANSIColor.pm
it seems colored() is supposed to add the reset for you.
"As an aid in resetting colors, colored() takes a scalar as the first argument and any number of attribute strings as the second argument and returns the scalar wrapped in escape codes so that the attributes will be set as requested before the string and reset to normal after the string."
I am currently working around this problem by importing the constants interface to my script
use Term::ANSIColor qw(:constants);
and then adding
print RESET;
between any log4perl lines and plain ol print statements I want to use which restores the behavior I think I'm used to.
I'm seeing this on Debian 7 with liblog-log4perl-perl 1.29-1 which has the version string
our $VERSION = '1.29';
in the /usr/share/perl5/Log/Log4perl.pm file
and Term::ANSIColor;
$VERSION = '3.00';
Michael Hicks
nooneofconsequence@gmail.com
Sometimes being wrong in interesting ways about interesting things is quite good for starting discussions.
Message body not shown because it is not plain text.